IOS关灯游戏_eqi 关灯游戏

//

// Game.m

// UIGame

//

// Created by Ibokan on12-8-21.

// Copyright (c) 2012年 __MyCompanyName__. All rights reserved.

//

#import "Game.h"

@implementation Game

- (id)initWithNibName:(NSString*)nibNameOrNil bundle:(NSBundle*)nibBundleOrNil

{

self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];

if (self) {

//Custom initialization

}

return self;

}

- (void)didReceiveMemoryWarning

{

// Releases the view if it doesn't have asuperview.

[superdidReceiveMemoryWarning];

// Release any cached data, images, etcthat aren't in use.

}

#pragma mark - View lifecycle

- (void)dealloc

{

[super dealloc];

}

// Implement viewDidLoad to do additional setup afterloading the view, typically from a nib.

- (void)viewDidLoad

{

[superviewDidLoad];

self.view.backgroundColor=[UIColorblackColor];

UIView * viewa=[[UIViewalloc]initWithFrame:CGRectMake(0, 0, 320, 460)];

viewa.backgroundColor=[UIColor blackColor];

//===================================================================================

//

// 利用for 循环 生成28个按钮 并为每个按钮的tag 赋值(100-127)

//

//===================================================================================

int x=100; //为了给每个tag 赋值

for (int i=0; i<4; i++){

for(int j=0;j<7; j++) {

UIButton * button=[UIButton buttonWithType:UIButtonTypeCustom];

button.frame=CGRectMake(20+77*i, 20+55*j, 48, 48);

[button setImage:[UIImage imageNamed:@"g.png"]forState:UIControlStateNormal];

button.tag= x++;

button.titleLabel.tag=1;

[viewa addSubview:button];

if(button.tag==106)

{

[button addTarget:self action:@selector(urClick:) forControlEvents:UIControlEventTouchUpInside];

}

else if(button.tag==113||button.tag==120)

{

[button addTarget:self action:@selector(ulrClick:) forControlEvents:UIControlEventTouchUpInside];

}

else if(button.tag==107||button.tag==114)

{

[button addTarget:self action:@selector(dlrClick:) forControlEvents:UIControlEventTouchUpInside];

}

else if(button.tag==121)

{

[buttonaddTarget:self action:@selector(dlClick:)forControlEvents:UIControlEventTouchUpInside];

}else

{

[buttonaddTarget:self action:@selector(udlrClick:)forControlEvents:UIControlEventTouchUpInside];

}

}

}

[self.view addSubview:viewa];

[viewarelease];

}

//===================================================================================

//

// 这是tag值为中间的10个按钮响应

//

//===================================================================================

#pragma mark - 点击事件一

- (void)udlrClick:(id)sender

{

UIButton *button = sender; //点击事件

UIButton * up; //上边

UIButton *down; //下边

UIButton *left; //左边

UIButton *right; //右边

[buttonsetImage:[UIImage imageNamed:@"h.png"]forState:UIButtonTypeCustom];

if (button.titleLabel.tag == 1){

[button setImage:[UIImageimageNamed:@"h.png"]forState:UIButtonTypeCustom];

button.titleLabel.tag =0;

} else {

[button setImage:[UIImageimageNamed:@"g.png"]forState:UIButtonTypeCustom];

button.titleLabel.tag =1;

}

up = (UIButton*)[self.view viewWithTag:button.tag-1];

if (up.titleLabel.tag == 1){

[up setImage:[UIImageimageNamed:@"h.png"]forState:UIButtonTypeCustom];

up.titleLabel.tag =0;

} else {

[up setImage:[UIImageimageNamed:@"g.png"]forState:UIButtonTypeCustom];

up.titleLabel.tag =1;

}

down =(UIButton *)[self.viewviewWithTag:button.tag+1];

if (down.titleLabel.tag == 1){

[down setImage:[UIImageimageNamed:@"h.png"]forState:UIButtonTypeCustom];

down.titleLabel.tag =0;

} else {

[down setImage:[UIImageimageNamed:@"g.png"]forState:UIButtonTypeCustom];

down.titleLabel.tag =1;

}

left =(UIButton *)[self.viewviewWithTag:button.tag-7];

if (left.titleLabel.tag == 1){

[left setImage:[UIImageimageNamed:@"h.png"]forState:UIButtonTypeCustom];

left.titleLabel.tag =0;

} else {

[left setImage:[UIImageimageNamed:@"g.png"]forState:UIButtonTypeCustom];

left.titleLabel.tag =1;

}

right =(UIButton *)[self.viewviewWithTag:button.tag+7];

if (right.titleLabel.tag == 1){

[right setImage:[UIImageimageNamed:@"h.png"]forState:UIButtonTypeCustom];

right.titleLabel.tag =0;

} else {

[right setImage:[UIImageimageNamed:@"g.png"]forState:UIButtonTypeCustom];

right.titleLabel.tag =1;

}

}

//===================================================================================

//

// 这是tag值为106个按钮响应 也就是左下角的

//

//===================================================================================

#pragma mark - 点击事件二

- (void)urClick:(id)sender

{

UIButton *button = sender; //点击的按钮

UIButton *up; //上边

UIButton *right; //右边

[buttonsetImage:[UIImage imageNamed:@"g.png"]forState:UIButtonTypeCustom];

if (button.titleLabel.tag == 1){

[button setImage:[UIImageimageNamed:@"h.png"]forState:UIButtonTypeCustom];

button.titleLabel.tag =0;

} else {

[button setImage:[UIImageimageNamed:@"g.png"]forState:UIButtonTypeCustom];

button.titleLabel.tag =1;

}

up = (UIButton*)[self.viewviewWithTag:button.tag-1];

if (up.titleLabel.tag == 1){

[up setImage:[UIImageimageNamed:@"h.png"]forState:UIButtonTypeCustom];

up.titleLabel.tag =0;

} else {

[up setImage:[UIImageimageNamed:@"g.png"]forState:UIButtonTypeCustom];

up.titleLabel.tag =1;

}

right =(UIButton *)[self.viewviewWithTag:button.tag+7];

if (right.titleLabel.tag == 1){

[right setImage:[UIImageimageNamed:@"h.png"]forState:UIButtonTypeCustom];

right.titleLabel.tag =0;

} else {

[right setImage:[UIImageimageNamed:@"g.png"]forState:UIButtonTypeCustom];

right.titleLabel.tag =1;

}

}

//===================================================================================

//

// 这是按钮最下一排 第2第3个 的事件

//

//===================================================================================

#pragma mark - 点击事件三

- (void)ulrClick:(id)sender

{

UIButton *button = sender; //点击的按钮

UIButton *up; //上边

UIButton *left; //左边

UIButton *right; //右边

[buttonsetImage:[UIImage imageNamed:@"h.png"]forState:UIButtonTypeCustom];

if (button.titleLabel.tag == 1){

[button setImage:[UIImageimageNamed:@"h.png"]forState:UIButtonTypeCustom];

button.titleLabel.tag =0;

} else {

[button setImage:[UIImage imageNamed:@"g.png"] forState:UIButtonTypeCustom];

button.titleLabel.tag = 1;

}

up =(UIButton *)[self.view viewWithTag:button.tag-1];

if (up.titleLabel.tag == 1) {

[upsetImage:[UIImageimageNamed:@"h.png"] forState:UIButtonTypeCustom];

up.titleLabel.tag = 0;

} else {

[upsetImage:[UIImageimageNamed:@"g.png"] forState:UIButtonTypeCustom];

up.titleLabel.tag = 1;

}

left =(UIButton *)[self.view viewWithTag:button.tag-7];

if (left.titleLabel.tag == 1) {

[left setImage:[UIImage imageNamed:@"h.png"] forState:UIButtonTypeCustom];

left.titleLabel.tag = 0;

} else {

[left setImage:[UIImage imageNamed:@"g.png"] forState:UIButtonTypeCustom];

left.titleLabel.tag = 1;

}

right =(UIButton *)[self.view viewWithTag:button.tag+7];

if (right.titleLabel.tag == 1) {

[right setImage:[UIImage imageNamed:@"h.png"] forState:UIButtonTypeCustom];

right.titleLabel.tag = 0;

} else {

[right setImage:[UIImage imageNamed:@"g.png"] forState:UIButtonTypeCustom];

right.titleLabel.tag = 1;

}

}

//===================================================================================

//

// 这是按钮最上一排 第2第3个 的事件

//

//===================================================================================

#pragma mark - 点击事件四

- (void)dlrClick:(id)sender

{

UIButton * button = sender;//点击事件

UIButton * down; //下边

UIButton * left; //左边

UIButton * ringht; //右边

[button setImage:[UIImageimageNamed:@"g.png"] forState:UIButtonTypeCustom];

if (button.titleLabel.tag == 1) {

[button setImage:[UIImage imageNamed:@"h.png"] forState:UIButtonTypeCustom];

button.titleLabel.tag = 0;

} else {

[button setImage:[UIImage imageNamed:@"g.png"] forState:UIButtonTypeCustom];

button.titleLabel.tag = 1;

}

down =(UIButton *)[self.view viewWithTag:button.tag+1];

if (down.titleLabel.tag == 1) {

[down setImage:[UIImage imageNamed:@"h.png"] forState:UIButtonTypeCustom];

down.titleLabel.tag = 0;

} else {

[down setImage:[UIImage imageNamed:@"g.png"] forState:UIButtonTypeCustom];

down.titleLabel.tag = 1;

}

left =(UIButton *)[self.view viewWithTag:button.tag-7];

if (left.titleLabel.tag == 1) {

[left setImage:[UIImage imageNamed:@"h.png"] forState:UIButtonTypeCustom];

left.titleLabel.tag = 0;

} else {

[left setImage:[UIImage imageNamed:@"g.png"] forState:UIButtonTypeCustom];

left.titleLabel.tag = 1;

}

ringht =(UIButton *)[self.view viewWithTag:button.tag+7];

if (ringht.titleLabel.tag == 1) {

[ringht setImage:[UIImage imageNamed:@"h.png"] forState:UIButtonTypeCustom];

ringht.titleLabel.tag = 0;

} else {

[ringht setImage:[UIImage imageNamed:@"g.png"] forState:UIButtonTypeCustom];

ringht.titleLabel.tag = 1;

}

}

//===================================================================================

//

// 这是按钮 右上角

//

//===================================================================================

#pragma mark - 点击事件五

- (void)dlClick:(id)sender

{

UIButton * button = sender; //点击的按钮

UIButton * down; //下边

UIButton * left; //左边

[button setImage:[UIImageimageNamed:@"g.png"] forState:UIButtonTypeCustom];

if (button.titleLabel.tag == 1) {

[button setImage:[UIImage imageNamed:@"h.png"] forState:UIButtonTypeCustom];

button.titleLabel.tag = 0;

} else {

[button setImage:[UIImage imageNamed:@"g.png"] forState:UIButtonTypeCustom];

button.titleLabel.tag = 1;

}

down =(UIButton *)[self.view viewWithTag:button.tag+1];

if (down.titleLabel.tag == 1) {

[down setImage:[UIImage imageNamed:@"h.png"] forState:UIButtonTypeCustom];

down.titleLabel.tag = 0;

} else {

[down setImage:[UIImage imageNamed:@"g.png"] forState:UIButtonTypeCustom];

down.titleLabel.tag = 1;

}

left =(UIButton *)[self.view viewWithTag:button.tag-7];

if (left.titleLabel.tag == 1) {

[left setImage:[UIImage imageNamed:@"h.png"] forState:UIButtonTypeCustom];

left.titleLabel.tag = 0;

} else {

[left setImage:[UIImage imageNamed:@"g.png"] forState:UIButtonTypeCustom];

left.titleLabel.tag = 1;

}

}

- (void)viewDidUnload

{

[superviewDidUnload];

// Release any retained subviews of themain view.

// e.g. self.myOutlet = nil;

}

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation

{

// Return YES for supportedorientations

return (interfaceOrientation == UIInterfaceOrientationPortrait);

}

@end

  

爱华网本文地址 » http://www.413yy.cn/a/25101011/87429.html

更多阅读

有什么手机游戏好玩? 有什么好玩的手机游戏

有什么手机游戏好玩?——简介 最近迷上了手机小游戏,没办法,谁叫那叫一个方便呢,那么今天就谈谈有什么手机游戏好玩吧,首先说明本屌是android手机,偏向于android系统哦,如果没有ios,请见谅哦,ok,一下游戏就以类型来分类吧。

最适合IPHONE5S的游戏推荐 iphone5s适合哪个系统

果粉们购买了IPHONE5S之后,很大一部分用途会用来玩游戏。作为一款高配置的手机,IPHONE5S可以玩儿的游戏更多,并且体验效果也是更好。今天就给大家推荐几款适合IPHONE5S的游戏,拥有IPHONE5S的朋友可不要错过啦。无尽之剑3要说起能体现

极难游戏2通关图文攻略 讨鬼传极图文攻略

极难游戏2通关图文攻略——简介 极难游戏2攻略(也就是史上最难游戏2攻略)来啦。这个不管在安卓平台还是IOS平台都异常火爆的游戏,别说是拿到S级评价了,就算是能够达到最低要求过关都有些难度 哦,安卓福利吧当然也不是神人,不可能每一关

IOS解密游戏The Room空房间详细图文攻略第二章 theroom第二章攻略

IOS解密游戏The Room空房间详细图文攻略第二章——简介此作的画面非常精美,谜题设计的也十分合理,真是居家必备的良品,游戏分为四章,火烧在接下来的几天里,会放出这四章的详细图文攻略,敬请期待,当然,也欢迎其他攻略快手的补完和解说,特别是

声明:《IOS关灯游戏_eqi 关灯游戏》为网友打板哥分享!如侵犯到您的合法权益请联系我们删除