游戏结构 -- from Space Viking & Learning Cocos2d

An Architecture in Cocos2d

Classes

GameplayLayer、BackgroundLayer、GameObject、GameCharacter、RadarDish、Viking

GameplayLayer : CCLayer 游戏Layer

CCSprite *vikingSprite; // 游戏主角
SneakyJoystick *leftJoystick; // 屏幕左侧游戏控制杆
SneakyButton *jumpButton; // 跳跃按钮
SneakyButton *attackButton; // 攻击按钮
CCSpriteBatchNode *sceneSpriteBatchNode; // 包含所有GameObject的CCSpriteBatchNode

BackgroundLayer : CCLayer 背景Layer

 

GameObject : CCSprite 游戏物体

BOOL isActive; // 是否活跃
BOOL reactsToScreenBoundaries; // 是否对平面边界做出反应
CGSize screenSize; // 屏幕大小
GameObjectType gameObjectType; // 物体类型
-(void)changeState:(CharacterStates)newState; // 转变状态
-(void)updateStateWithDeltaTime:(ccTime)deltaTime andListOfGameObjects:(CCArray*)listOfGameObjects; // 每帧更新一次状态
-(CGRect)adjustedBoundingBox; // 调整后的包围盒
-(CCAnimation*)loadPlistForAnimationWithName:(NSString*)animationName andClassName:(NSString*)className; // 通过plist文件获得动画基本信息

GameCharacter : GameObject 游戏角色

int characterHealth; // 健康值
CharacterStates characterState; // 角色状态
-(void)checkAndClampSpritePosition; // 检查并调整角色位置
-(int)getWeaponDamage; //获得该角色提供的伤害值

RadarDish : GameCharacter 雷达

// animations
CCAnimation *...; // 各种动画
GameCharacter *vikingCharacter; // 主角

Viking : GameCharacter

LastPunchType myLastPunch; // 上次攻击时使用的手
BOOL isCarryingMallet; // 是否有木棍
CCSpriteFrame *standingFrame; // viking站着时的frame
// animations
CCAnimation *...; // 各种动画
SneakyJoystick *joystick; // 游戏杆
SneakyButton *jumpButton; // 跳跃按钮
SneakyButton *attackButton; // 攻击按钮
float millisecondsStayingIdle; // 休闲时间的毫秒数

转载于:https://www.cnblogs.com/ketmales/archive/2013/01/03/2843259.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值