资源描述
《记忆游戏》项目开发书
指导教师:佘莹莹
开发人员:马 特 赵睿
贾静芸 蓝婧
专业名称:数字媒体艺术
年 级: 2009 级
2012年11月11日
14
目录
一.游戏综述 3
1.1游戏简介 3
1.2开发平台 3
1.3开发工具 3
1.4游戏开发时间表 3
1.5游戏开发者分工 4
二.游戏相关界面展示 5
2.1主菜单 5
2.2开发信息界面 5
2.3游戏设置界面 6
2.4游戏主场景 6
2.5最高分 7
三.游戏模块设计 8
3.1游戏中主要类的关系 8
四.游戏主要的类设计 8
4.1游戏中的主要类设计一览表 8
4.2AppDelegate部分的类设计如下 9
4.3GameViewController的设计思路如下: 10
4.4HSViewController设计如下: 11
4.5InfoViewController的设计 11
4.6MenuviewController的设计 12
4.7SettingViewController 12
4.8SwitchViewController 13
五.附录:游戏相关重要代码 13
一.游戏综述
1.1游戏简介
游戏中有16个卡片,两两一对。每次玩家可以翻开两张牌。如果两张牌能够配对,则消去卡片,否则,卡片反转过去,直到卡片全部消去为止。此时会显示玩家一共翻动过的次数,游戏中会记录最高分highscore。
1.2开发平台
IOS平台(IOS 5/ IOS 4)
1.3开发工具
XCode(IOS版本)/cocos 2d/cocos 2d-x
1.4游戏开发时间表
时间
美工
代码
第一周
游戏原型设计
UI初步设计
熟悉开发环境,设计游戏框架
第二周
第三周
第四周
界面背景绘制
游戏主场景
第五周
UI控件绘制
第六周
游戏UI设计与绘制并持续完善
第七周
游戏道具设计与绘制并持续完善、场景设计与绘制
游戏其他界面
第八周
场景设计与绘制
代码完善,测试,提交成品
第九周
配合代码编写人员对美工部分进行完善,提交成品
1.5游戏开发者分工
1. 游戏策划:
马特,赵睿,蓝婧,贾静芸
2. 游戏开发文档:
马特,蓝婧
3. 游戏界面
贾静芸,蓝婧
4. 音效设计:
贾静芸
5. 按钮和菜单设计:
贾静芸,赵睿
6. 代码部分:
赵睿,马特,贾静芸,蓝婧
二.游戏相关界面展示
2.1主菜单
2.2开发信息界面
2.3游戏设置界面
2.4游戏主场景
2.5最高分
三.游戏模块设计
3.1游戏中主要类的关系
四.游戏主要的类设计
4.1游戏中的主要类设计一览表
类名
功能
说明
AppDelegate
实现游戏中的代理
基础类
GameViewController
游戏中视图控制类
基础类
HSViewController
有关最高分的控制
应用程序类
InfoViewController
介绍相关信息
应用程序类
MenuViewController
主场景的控制
应用程序类
SettingsViewController
游戏设置部分的控制
应用程序类
SwitchViewController
控制界面的切换
应用程序类
4.2AppDelegate部分的类设计如下
类成员
类方法或类型
返回值或类型
说明
window
实例变量
Void
窗口
switchViewController
实例变量
Void
切换视角的控制器
AVAudioPlayer *musicPlayer
静态变量
AVAudioPlayer*
控制音乐播放
Music
实例变量
Bool
声音对象
Sound
实例变量
Bool
音效对象
hardSetMusic,
实例变量
Static bool
控制声音的改变
hardSetSound
实例变量
Static bool
控制音效
application:(UIApplication *)
application didFinishLaunchingWithOptions:
(NSDictionary *)launchOptions
类方法
Void
控制窗口的启动
toggleMusic
类方法
Void
停止音乐的播放
toggleSound
类方法
Void
停止播放音效
toggleHardMusic
类方法
Void
背景音乐
toggleHardSound
类方法
Void
音效
getMusic
类方法
Bool
无
getSound
类方法
Bool
同上
getHardMusic
类方法
Bool
同上
getHardSound
类方法
Bool
同上
setHardMusic
类方法
Void
同上
setHardSound
类方法
Void
同上
setPlayer
类方法
void
同上
applicationWillResignActive
类方法
Void
系统自带
applicationDidEnterBackground
类方法
Void
系统自带
applicationWillEnterForeground
类方法
Void
系统自带
applicationDidBecomeActive
类方法
Void
系统自带
applicationWillTerminate
类方法
Void
系统自带
4.3GameViewController的设计思路如下:
成员名称
变量或方法
返回值或类型
说明
imageviews
属性
NSArray *
topToolbar
属性
UINavigationBar *
bottomToolbar
属性
UINavigationBar *
pairsFoundCounter
属性
NSInteger
是否找到对数
turnsTakenText
属性
UILabel *
显示用过的次数
pairsFoundText
属性
UILabel *
显示对数
turnsTakenText
属性
UILabel *
muteButton
属性
UIBarButtonItem *
声音按钮
cards
属性
NSArray *
assignments
属性
NSMutableArray *
scores
属性
NSMutableArray *
flippedCards,
属性
NSInteger
lastCardIndex,
属性
NSIneger
pairsFound,
属性
NSInteger
currentCardIndex
属性
NSInteger
当前卡片索引
turnsTakenCounter
属性
NSInteger
使用的次数
soundPlayer
静态变量
AVAudioPlayer *
声音对象
sound
静态变量
bool
音效
volumeToggle
实例方法
IBAction
音效的调节
didReceiveMemoryWarning
实例方法
Void
内存分配提示出错信息
viewDidLoad
实例方法
Void
界面加载成功
cardClicked
实例方法
IBAction
点击卡片的事件
flipCardsBack
实例方法
Void
卡片翻面的事件
winGame
实例方法
Void
游戏成功
quitGame
实例方法
IBAction
游戏退出
viewDidUnload
实例方法
Void
界面加载成功
viewDidAppear
实例方法
Void
销毁声音对象
viewWillDisappear:
实例方法
Void
无
viewDidDisappearnimated
类方法
Void
无
4.4InfoViewController的设计
类成员
变量或方法
返回值或类型
说明
mobiLabel
属性
UILabel
backToMenu:(id)sender
实例方法
IBAction
返回
initWithNibName
实例方法
Id
初始化
didReceiveMemoryWarning
实例方法
Void
内存分配出错
viewDidLoad
实例方法
Void
viewDidUnload
实例方法
Void
touchesBegan
实例方法
Void
触摸开始
4.5MenuviewController的设计
成员名
变量和方法
返回值或类型
说明
playButton
属性
IBoutletUIButton
按钮
initWithNibName
实例方法
Id
初始化
singlePlayerGame
实例方法
IBAction
单人游戏
infoScreen
实例方法
IBAction
消息
settingsScreen
实例方法
IBAction
设置
hsScreen
实例方法
IBAction
高分
didReceiveMemoryWarning
实例方法
Void
loadView
实例方法
Void
viewDidLoad
实例方法
Void
viewDidUnload
实例方法
Void
4.6SettingViewController
成员名
变量和方法
返回值
说明
musicSwitch
属性
UISwitch *
soundSwitch
属性
UISwitch *
backToMenu
实例方法
IBAction
toggleMusic
实例方法
IBAction
toggleSound
实例方法
IBAction
initWithNibName
实例方法
Id
didReceiveMemoryWarning
实例方法
Void
4.7SwitchViewController
成员名
变量和方法
返回值
说明
gameViewController
实例变量
GameViewController *
游戏界面controller
menuViewController
实例变量
MenuViewController *
菜单controller
infoViewController
实例变量
InfoViewController *
关于界面controller
settingsViewController
实例变量
SettingsViewController *
设置界面controller
hsViewController
实例变量
HSViewController *
最高分界面controller
switchToGame
类方法
Void
switchToMenu
类方法
Void
switchToInfo
类方法
Void
switchToSettings
类方法
Void
switchToHighScore
类方法
Void
viewDidLoad
实例方法
void
didReceiveMemoryWarning
实例方法
void
viewDidUnload
实例方法
void
shouldAutorotateToInterfaceOrientation
实例方法
BOOL
五.附录:游戏相关重要代码
//------声音-----------
-(IBAction)volumeToggle:(id)sender{
if(sound){
self.muteButton.image=[UIImage imageNamed:@"sound-off.png"];
if([AppDelegate getMusic]==true)
[AppDelegate toggleMusic];
if([AppDelegate getSound]==true)
[AppDelegate toggleSound];
sound=false;
if([[AppDelegate getPlayer] isPlaying])
[[AppDelegate getPlayer] stop];
}else{
self.muteButton.image=[UIImage imageNamed:@"sound.png"];
sound=true;
if([AppDelegate getHardMusic]==true)
[AppDelegate toggleMusic];
if([AppDelegate getHardSound]==true)
[AppDelegate toggleSound];
if([AppDelegate getMusic]&&[[AppDelegate getPlayer] isPlaying]==false){
[[AppDelegate getPlayer] play];
}
}
}
//--------翻卡片----------
- (IBAction)cardClicked:(id)sender{
if(sound)
if([AppDelegate getSound]){
NSString *filePath = [[NSBundle mainBundle] pathForResource:@"flip" ofType:@"caf"];
NSURL *fileURL = [[NSURL alloc] initFileURLWithPath:filePath];
soundPlayer = [[AVAudioPlayer alloc] initWithContentsOfURL:fileURL error:nil];
soundPlayer.numberOfLoops=0;
[soundPlayer play];
}
//get the car index from the UIButton's tag value.
NSInteger index = [sender tag];
[sender setImage:[cards objectAtIndex:[[assignments objectAtIndex:index] intValue]] forState:UIControlStateNormal];
[sender setImage:[cards objectAtIndex:[[assignments objectAtIndex:index] intValue]] forState:UIControlStateDisabled];
[sender setEnabled:NO];
flippedCards ++;
if(flippedCards == 2){
currentCardIndex = index;
//disable all the cards for the next second
for(int i = 0; i < 16; i++){
if(i != lastCardIndex && i != currentCardIndex){
[[imageviews objectAtIndex:i] setImage:[cards objectAtIndex:8] forState:UIControlStateDisabled];
}
[[imageviews objectAtIndex:i] setEnabled:NO];
}
//set up a timer to turn the cards back over after 1 second
[NSTimer scheduledTimerWithTimeInterval:1.0
target:self
selector:@selector(flipCardsBack)
userInfo:nil
repeats:NO];
flippedCards = 0;
}else{
lastCardIndex = index;
}
}
//------判断两张卡片是否相消--------------
if(i != lastCardIndex && i != currentCardIndex){
[[imageviews objectAtIndex:i] setImage:[cards objectAtIndex:8] forState:UIControlStateDisabled];
}
[[imageviews objectAtIndex:i] setEnabled:NO];
展开阅读全文