MainView.m
资源名称:PushBox.rar [点击查看]
上传用户:qhdwjd2004
上传日期:2020-12-29
资源大小:362k
文件大小:5k
源码类别:
iPhone
开发平台:
Objective-C
- #import "MainView.h"
- @implementation MainView
- - (id)initWithFrame:(CGRect)rect
- {
- if ((self == [ super initWithFrame: rect ]) != nil) {
- viewRect = rect;
- // -------------------- init --------------------
- aEffect = [[NSArray alloc] initWithObjects:
- @"pageCurl",@"pageUnCurl",
- @"suckEffect",@"spewEffect",
- @"genieEffect",@"unGenieEffect",
- @"swirl",@"rippleEffect",
- @"twist",@"tubey",
- @"oglFlip",nil
- ];
- // -------------------- init transView --------------------
- transView = [ [ UITransitionView alloc ] initWithFrame: viewRect ];
- [ self addSubview: transView ];
- // -------------------- init messageSheet --------------------
- messageSheet = [[UIAlertSheet alloc] initWithFrame : CGRectMake(0,240,320,240)];
- [messageSheet setDestructiveButton :[messageSheet addButtonWithTitle:@"OK"]];
- [messageSheet setDelegate: self];
- // -------------------- init coverView --------------------
- coverView = [[CoverView alloc] initWithFrame: viewRect];
- [coverView setParentView: self];
- // -------------------- init gameView --------------------
- gameView = [[GameView alloc] initWithFrame: viewRect];
- [gameView setParentView: self];
- // -------------------- init listView --------------------
- listView = [[ListView alloc] initWithFrame: viewRect];
- [listView setParentView: self];
- // -------------------- init settingView --------------------
- settingView = [[SettingView alloc] initWithFrame: viewRect];
- [settingView setParentView: self];
- // -------------------- init aboutView --------------------
- aboutView = [[AboutView alloc] initWithFrame: viewRect];
- [aboutView setParentView: self];
- [self transTo: coverView];
- }
- return self;
- }
- - (void)dealloc
- {
- [ self dealloc ];
- [ super dealloc ];
- }
- //////////////////////////////////////////////////////
- // 公共函数
- //////////////////////////////////////////////////////
- // 显示提示信息
- - (void)showMessage:(NSString *)msg Title:(NSString *)title
- {
- [messageSheet setTitle: title];
- [messageSheet setBodyText: msg];
- [messageSheet popupAlertAnimated:YES];
- }
- -(void)alertSheet:(UIAlertSheet*)sheet buttonClicked:(int)button
- {
- [sheet dismiss];
- }
- // 切换视图
- - (void)showView:(int)viewname
- {
- switch(viewname)
- {
- case COVERVIEW:
- [self transTo: coverView];
- break;
- case GAMEVIEW:
- [self transTo: gameView];
- break;
- case LISTVIEW:
- [self transTo: listView];
- break;
- case SETTINGVIEW:
- [self transTo: settingView];
- break;
- case ABOUTVIEW:
- [self transTo: aboutView];
- break;
- }
- }
- // 切换视图
- - (void)transTo:(UIView *)view
- {
- LKAnimation *animation = [ LKTransition animation ];
- [ animation setType: [aEffect objectAtIndex:[Map GetRandNum] % 11]];
- [ animation setSubtype: @"fromLeft"];
- [ animation setTimingFunction:
- [ LKTimingFunction functionWithName: @"easeInEaseOut"]];
- [ animation setFillMode: @"extended" ];
- [ animation setTransitionFlags: 3 ];
- [ animation setSpeed: 0.50 ];
- [ [ self _layer ] addAnimation: animation forKey: 0 ];
- [ transView transition: 0 toView: view ];
- }
- // 显示封面
- - (void)showCover
- {
- [coverView updateview];
- [self transTo: coverView];
- }
- // 设备方向发生改变
- - (void)orientationChanged:(int)orientation
- {
- if([gameView IsPlaying])
- {
- [gameView changeOrientation:orientation];
- }
- }
- // 程序将退出
- - (void)appWillExit
- {
- if([gameView IsPlaying])
- {
- [gameView save];
- }
- }
- //////////////////////////////////////////////////////
- // 菜单响应
- //////////////////////////////////////////////////////
- // 开始游戏
- - (void)startGame
- {
- Mess mdata;
- if([Map CheckMessExist])
- {
- mdata = [Map LoadMess];
- }
- else
- {
- mdata.enableChapterCount = 1;
- }
- mdata.chapterIndex = 0;
- mdata.isCustom=NO;
- [Map LoadChapter:mdata.chapterIndex Data:mdata.mapdata];
- [gameView load:mdata];
- [self transTo:gameView];
- }
- // 继续游戏
- - (void)continueGame
- {
- Mess mdata = [Map LoadMess];
- [gameView load:mdata];
- [self transTo:gameView];
- }
- // 选择关卡
- - (void)customGame:(bool)isCustomMap
- {
- if(isCustomMap)
- {
- [listView loadMapList];
- }
- else
- {
- [listView loadChapterList];
- }
- [self transTo:listView];
- }
- // 显示关于
- - (void)showAbout
- {
- [self transTo:aboutView];
- }
- // 关卡被选择
- -(void)characterSelected:(int)cindex
- {
- Mess mdata = [Map LoadMess];
- mdata.chapterIndex = cindex;
- mdata.isCustom=NO;
- [Map LoadChapter:mdata.chapterIndex Data:mdata.mapdata];
- [gameView load:mdata];
- [self transTo:gameView];
- }
- // 自定义地图被选择
- -(void)mapSelected:(NSString*)mappath
- {
- Mess mdata = [Map LoadMess];
- mdata.isCustom=YES;
- [Map LoadMap:mappath Data:mdata.mapdata];
- [gameView load:mdata];
- [self transTo:gameView];
- }
- @end