关灯游戏java代码_关灯小游戏的基本代码实现

1 #import "RegisterViewController.h"

2 #import "LTView.h"

3 #import "GameViewController.h"

4 #import "ViewController.h"

5 @interfaceRegisterViewController ()6 {7 LTView *_userName;8 LTView *_password;9

10 }11 @end

12

13 @implementationRegisterViewController14

15 - (void)viewDidLoad {16 [super viewDidLoad];17 self.view.backgroundColor=[UIColor grayColor];18

19 UIImageView *image=[[UIImageView alloc]initWithFrame:[UIScreen mainScreen].bounds];20 [image setImage:[UIImage imageNamed:@"fj.jpg"]];21 [self.view addSubview:image];22

23 _userName=[[LTView alloc]initWithFrame:CGRectMake(0,150, 320, 30) text:@"用户名" background:[UIColor grayColor] fontSize:18 alignment:NSTextAlignmentCenter textColor:[UIColor blackColor] percent:0.28 interval:10 textField:@"525655828" borderStyle:UITextBorderStyleRoundedRect returnKeyType:UIReturnKeyDone keyboardType:UIKeyboardTypeNumberPad placeholder:@"请输入用户名"secureTextEntry:NO clearButtonMode:UITextFieldViewModeWhileEditing24 clearsOnBeginEditing:YES delegate:self];25 [self.view addSubview:_userName];26 _password=[[LTView alloc]initWithFrame:CGRectMake(0, 230, 320, 30) text:@"密码" background:[UIColor grayColor] fontSize:18 alignment:NSTextAlignmentCenter textColor:[UIColor blackColor] percent:0.28 interval:10 textField:@"12345678" borderStyle:UITextBorderStyleRoundedRect returnKeyType:UIReturnKeyDone keyboardType:UIKeyboardTypeDefault placeholder:@"请输入密码" secureTextEntry:YES clearButtonMode:UITextFieldViewModeWhileEditing clearsOnBeginEditing:YES delegate:self];27 [self.view addSubview:_password];28 UIButton *registe=[[UIButton alloc]initWithFrame:CGRectMake(120, 310, 80, 30)];29 [registe setBackgroundColor:[UIColor greenColor]];30 [registe.layer setBorderColor:(__bridge CGColorRef)([UIColor redColor])];31 [registe.layer setCornerRadius:10];32 [registe.layer setBorderWidth:1];33 [registe setTitle:@"开始游戏"forState:UIControlStateNormal];34 [registe setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];35 [registe setTitleColor:[UIColor redColor] forState:UIControlStateHighlighted];36 registe.titleLabel.font=[UIFont systemFontOfSize:18];37 [self.view addSubview:registe];38 [registe addTarget:self action:@selector(doClickRegister) forControlEvents:UIControlEventTouchDown];39 }40 -(void)doClickRegister41 {42 UIAlertView *alertView=[[UIAlertView alloc]initWithTitle:@"欢迎回到游戏" message:@"请选择想要进入的游戏" delegate:self cancelButtonTitle:@"返回" otherButtonTitles:@"开始游戏", nil];43 [alertView show];44 }45 -(void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex46 {47 if (buttonIndex==0) {48 [self.navigationController pushViewController:[[ViewController alloc]init] animated:YES];49

50 }51 if (buttonIndex==1) {52 [self.navigationController pushViewController:[[GameViewController alloc]init] animated:YES];53 }54 }55 //触摸屏幕退出键盘

56 -(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event

57 {58 [self.view endEditing:YES];59 }60 - (void)didReceiveMemoryWarning {61 [super didReceiveMemoryWarning];62 //Dispose of any resources that can be recreated.

63 }64

65 /*

66 #pragma mark - Navigation67

68 // In a storyboard-based application, you will often want to do a little preparation before navigation69 - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {70 // Get the new view controller using [segue destinationViewController].71 // Pass the selected object to the new view controller.72 }73 */

74

75 @end

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值