UI关灯游戏 代码
来源:互联网 发布:flag在c语言中的用法 编辑:程序博客网 时间:2024/04/27 20:22
#import "GameViewController.h"
@interface GameViewController ()
@end
@implementation GameViewController
- (void) dealloc
{
[_nameLabel release];
_nameLabel = nil;
[superdealloc];
}
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
self = [superinitWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self) {
// Custom initialization
}
return self;
}
- (void)viewDidLoad
{
[superviewDidLoad];
// Do any additional setup after loading the view.
_nameLabel =[[UILabelalloc] initWithFrame:CGRectMake(60,20, 200, 40)];
[_nameLabelsetBackgroundColor:[UIColorwhiteColor]];
[_nameLabelsetText:@"白雪公主的黑暗骑士丶"];
UIFont * font = [UIFontboldSystemFontOfSize:20];
[_nameLabelsetFont:font];
[_nameLabelsetTextAlignment:NSTextAlignmentCenter];
[_nameLabelsetTextColor:[UIColorredColor]];
[self.viewaddSubview:_nameLabel];
[_nameLabel release];
UILabel * ziLabel = [[UILabelalloc] initWithFrame:CGRectMake(60,420, 200, 40)];
[ziLabel setBackgroundColor:[UIColorwhiteColor]];
[ziLabelsetText:@"小火龙丶就决定是你了"];
UIFont * font1 = [UIFontboldSystemFontOfSize:20];
[ziLabelsetFont:font1];
[ziLabel setTextAlignment:NSTextAlignmentCenter];
[ziLabel setTextColor:[UIColorredColor]];
[self.viewaddSubview:ziLabel];
[ziLabelrelease];
[selfcreatImageButton];
}
- (void) creatImageButton
{
int tag = 1;
for (int i =0; i < 7; i++) {
for (int j =0; j < 6; j++) {
UIButton * button = [[UIButtonalloc] initWithFrame:CGRectMake(10 +50 * j, 70 +50 * i, 50,50)];
[button setImage:[UIImageimageNamed:@"321.png"]forState:UIControlStateNormal];
[button setImage:[UIImageimageNamed:@"000.png"]forState:UIControlStateSelected];
[button addTarget:selfaction:@selector(buttonAction:)forControlEvents:UIControlEventTouchUpInside];
[buttonsetTag:tag++];
[self.viewaddSubview:button];
[buttonrelease];
}
}
}
- (void) buttonAction:(UIButton*)sender
{
NSLog(@"%d",sender.tag);
[sendersetSelected:![sender isSelected]];
if ((sender.tag %6 != 1) ) {
UIButton * abutton = (UIButton*)[self.viewviewWithTag:sender.tag-1];
[abuttonsetSelected:![abutton isSelected]];
}
if ((sender.tag %6 != 0) ) {
UIButton * abutton = (UIButton*)[self.viewviewWithTag:sender.tag+1];
[abuttonsetSelected:![abutton isSelected]];
}
if (sender.tag >6) {
UIButton * abutton = (UIButton*)[self.viewviewWithTag:sender.tag-6];
[abuttonsetSelected:![abutton isSelected]];
}
if (sender.tag <37) {
UIButton * abutton = (UIButton*)[self.viewviewWithTag:sender.tag+6];
[abuttonsetSelected:![abutton isSelected]];
}
}
---------------------------------分割线---------------------------------------
GameViewController.h
#import <UIKit/UIKit.h>
@interface GameViewController :UIViewController
//显示游戏名
@property (retain,nonatomic) UILabel * nameLabel;
@end
#import "AppDelegate.h"
#import "GameViewController.h"
@implementation AppDelegate
- (void) dealloc
{
[_windowrelease];
_window = nil;
[superdealloc];
}
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
self.window = [[UIWindowalloc] initWithFrame:[[UIScreenmainScreen] bounds]];
// Override point for customization after application launch.
self.window.backgroundColor = [UIColorwhiteColor];
GameViewController * game = [[GameViewControlleralloc] init];
[self.windowsetRootViewController:game];
[self.windowmakeKeyAndVisible];
return YES;
}
- UI关灯游戏 代码
- IOS UI 关灯游戏
- UI游戏实现 关灯游戏
- 关灯游戏,UI教程第二节百行代码解决
- 关灯游戏代码
- 初学UI之关灯游戏
- UI, 关灯游戏的实现
- UI 代码 关灯小游戏 demo
- 百行代码搞定“关灯游戏”!!!
- 我自己的关灯游戏代码
- 关灯游戏
- 关灯游戏
- 关灯游戏
- 关灯游戏
- 关灯游戏
- 关灯游戏
- 关灯游戏
- 关灯游戏
- 程序员如何找个白富美!!!
- VB.NET视频总结——基础篇
- Android 4 components
- BD和ts是什么意思
- 一个阻塞队列引发的死锁和伪唤醒
- UI关灯游戏 代码
- VS2010编译警告:warning C4996: 'strcpy': This function
- vijos1579
- OC关灯游戏
- Word2013插入分隔符(分节符)实现任意页插入页码
- map data yet available
- 到处excel表格
- Python的包管理工具pip安装指南
- 江苏2012年高考零分作文非诚勿扰版