简单的没有关卡的关灯游戏-创新互联
有两个图片
创新互联长期为千余家客户提供的网站建设服务,团队从业经验10年,关注不同地域、不同群体,并针对不同对象提供差异化的产品和服务;打造开放共赢平台,与合作伙伴共同营造健康的互联网生态环境。为魏县企业提供专业的成都做网站、网站制作、成都外贸网站建设,魏县网站改版等技术服务。拥有10余年丰富建站经验和众多成功案例,为您定制开发。新建一个CloseLight类
CloseLight.h
import@interface CloseLight : UIViewController @property (nonatomic , assign)NSInteger tag; @end
CloseLight.m
#import "CloseLight.h" @interface CloseLight () @end @implementation CloseLight - (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil { self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil]; if (self) { // Custom initialization } return self; } - (void)viewDidLoad { [super viewDidLoad]; self.view.backgroundColor = [UIColor whiteColor]; // Do any additional setup after loading the view. UIView *view = [[UIView alloc] initWithFrame:CGRectMake(15, 50, 290, 310)]; view.backgroundColor = [UIColor brownColor]; view.layer.cornerRadius = 10; [self.view addSubview:view]; [view release]; _tag = 10000; for (int i = 0; i < 5; i++) { for (int j = 0; j < 5; j ++) { UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom]; [button setFrame:CGRectMake(10 + 10 * j + 45 * j, 14 + 14 * i + 45 * i, 50, 50)]; // [button setBackgroundColor:[UIColor redColor]]; [button setBackgroundImage:[UIImage p_w_picpathNamed:@"1"] forState:UIControlStateNormal]; button.layer.cornerRadius = 5; [button addTarget:self action:@selector(gobutton:) forControlEvents:UIControlEventTouchUpInside]; button.tag = _tag +1000 *(i + 1) + (j + 1); [view addSubview:button]; } } UIButton *button = [UIButton buttonWithType:UIButtonTypeSystem]; [button setTitle:@"开始游戏" forState:UIControlStateNormal]; button.frame = CGRectMake(120, 310, 60, 30); [button addTarget:self action:NULL forControlEvents:UIControlEventTouchUpInside]; [view addSubview:button]; } - (void)change:(UIButton *)button { // UIColor *newColor = button.backgroundColor; UIImage *p_w_picpath = [button backgroundImageForState:1]; if (p_w_picpath == [UIImage p_w_picpathNamed:@"1"]) { // [button setBackgroundColor:[UIColor blackColor]]; [button setBackgroundImage:[UIImage p_w_picpathNamed:@"2"] forState:UIControlStateNormal]; }else if(p_w_picpath == [UIImage p_w_picpathNamed:@"2"]){ // [button setBackgroundColor:[UIColor redColor]]; [button setBackgroundImage:[UIImage p_w_picpathNamed:@"1"] forState:UIControlStateNormal]; } } - (void)gobutton:(id)sender { UIButton *newbutton = (UIButton *)sender; [self change:(UIButton *)[self.view viewWithTag:newbutton.tag] ]; [self change:(UIButton *)[self.view viewWithTag:newbutton.tag + 1]]; [self change:(UIButton *)[self.view viewWithTag:newbutton.tag - 1]]; [self change:(UIButton *)[self.view viewWithTag:newbutton.tag + 1000]]; [self change:(UIButton *)[self.view viewWithTag:newbutton.tag - 1000]]; } - (void)didReceiveMemoryWarning { [super didReceiveMemoryWarning]; // Dispose of any resources that can be recreated. }
AppDelegate.m
#import "AppDelegate.h" #import "CloseLight.h" @implementation AppDelegate - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]]; // Override point for customization after application launch. self.window.backgroundColor = [UIColor whiteColor]; [self.window makeKeyAndVisible]; CloseLight *light = [[CloseLight alloc] init]; self.window.rootViewController = light; [_window release]; return YES; } - (void)dealloc { [_window release]; [super dealloc]; } - (void)applicationWillResignActive:(UIApplication *)application { // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state. // Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game. } - (void)applicationDidEnterBackground:(UIApplication *)application { // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later. // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits. } - (void)applicationWillEnterForeground:(UIApplication *)application { // Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background. } - (void)applicationDidBecomeActive:(UIApplication *)application { // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface. } - (void)applicationWillTerminate:(UIApplication *)application { // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:. } @end附件:http://down.51cto.com/data/2364827
另外有需要云服务器可以了解下创新互联scvps.cn,海内外云服务器15元起步,三天无理由+7*72小时售后在线,公司持有idc许可证,提供“云服务器、裸金属服务器、高防服务器、香港服务器、美国服务器、虚拟主机、免备案服务器”等云主机租用服务以及企业上云的综合解决方案,具有“安全稳定、简单易用、服务可用性高、性价比高”等特点与优势,专为企业上云打造定制,能够满足用户丰富、多元化的应用场景需求。
网站名称:简单的没有关卡的关灯游戏-创新互联
分享网址:http://myzitong.com/article/cecehs.html