关于cocos2d x论坛-x中demo的使用

Cocos2d-x官方Demo中英文对照&&ActionsTest
如果文章对您有所帮助,欢迎给作者捐赠,支持笨木头的独立游戏工作,捐赠数额随意,重在心意^_^ +
之前对官方Demo的例子有点混乱,实在是太多了,每次想看看Cocos2d-x是否支持某个功能,都要点一遍官方例子的程序。所以我就把目录索引出来,并加上中文翻译了。
当然了,这是蛮久之前整的,有些例子自己也还没有跑过,也许有翻译得不对的地方,仅供参考,以实际效果为准。
笨木头花心贡献,啥?花心?不呢,是用心~
转载请注明,原文地址:
1) Manual Transformation 设置透明度、颜色、旋转角度
2) MoveTo / MoveBy 移动到某个点后停止/移动指定距离
3) ScaleTo / ScaleBy 缩放至某个值 / 缩放指定值
4) RotateTo / RotateBy 旋转至某个值 / 旋转指定值
5) SkewTo / SkewBy 横切至某个值 / 横切指定值
6) Skew + Rotate + Scale 组合
7) JumpTo / JumpBy 弹跳至某个点 / 弹跳指定距离
8) CardinalSplineBy / CardinalSplineAt 沿着给定路径移动(基数样条?)
9) CatmullRomBy / CatmullRomTo沿着给定路径移动(卡特姆线?)
10) BezierBy / BezierTo 沿着给定路径移动(贝赛尔曲线)
11) Blink 闪烁
12) FadeIn / FadeOut 淡进淡出
13) TintTo / TintBy 色彩渐变
14) Manual Animation 根据plist文件创建精灵动画
15) Sequence:Move + Rotate 移动和旋转
16) Sequence of InstantActions 三种精灵动画回调
17) Spawn: Jump + Rotate 跳跃和旋转
18) Reverse an action 逆向还原一个动作
19) DelayTime: m + delay + m 设置动作停顿时间
20) Repeat / RepeatForever 重复动作 / 永久重复动作
21) CallFuncN + RepeatForever 回调和永久重复动作
22) Repeat / RepeatForever + Rotate To 重复和旋转
23) RepeatForever / Repeat + Rotate
24) Callbacks: CallFunc and friends
25) CallFuncNd + auto remove 回调和自动移除
26) Reverse a sequence 逆向重复矩形移动
27) Reverse sequence2
28) OrbitCamera action 轨迹镜头动画?
29) Follow Action 视角跟随精灵移动
30) ActionTargeted 应该是一个精灵的动作,运行在另一个精灵身上?
31) PauseResumeAction 暂停和恢复动作
32) Issue 1305 在精灵出现后打印日志(回调?)
33) Issue 1305 #2 在精灵移动到某个点停止时打印日志。
34) Issue 1288 #2 精灵移动100个像素后停止
35) Issue 1327 You should see: 0, 45, 90, 135, 180,打印了精灵旋转角度
-------------------------------------------------------- End --------------------------------------------------------
如果文章对您有所帮助,欢迎给作者捐赠,支持笨木头的独立游戏工作,捐赠数额随意,重在心意^_^ +
---------------------------------------------------------------------------------------------------------------------
<a href='/item.htm?spm=686.iI7AI&id=' alt="Cocos2d-x3.0
【上一篇】【下一篇】
这货是木头
博主:笨木头
关注:Cocos2d-x
访问:164470 次
----------------------------
木系Cocos2d-x群(满):
Cocos2d-x①号小群:
----------------------------
Cocos2d-x游戏源码:
Cocos2d-x网游源码:
赞助一下,点你喜欢
只看感兴趣的
木头的新书出版喇
大家都在讨论 也许你用得上
大家都在关注cocos2d-x - 滚动列表(类似天天酷跑道具菜单)详解(CCScrollView的使用) - 推酷
cocos2d-x - 滚动列表(类似天天酷跑道具菜单)详解(CCScrollView的使用)
已收藏到推刊!
请填写推刊名
描述不能大于100个字符!
权限设置: 公开
仅自己可见
今天要写一个滚动列表功能,类似下面这样。(图片资源都是自己从天天酷跑里面抠的,仅用于学习方便)
首先,这样一个列表就和iOS里面的UITableView没什么两样,当然,Android中肯定也存在类似的控件。
在cocos2d-x引擎中参照ios中的UITableView实现了一个叫做CCTableView的类,用于创建列表,对于熟悉ios程序设计的人来说,这个内容应该是很好理解的。
下面就介绍下CCTableView。
首先,mark几个比较好的博文。
另外.先介绍下涉及的几个常用方法。
必须实现:
//触摸到某个cell的事件
virtual void tableCellTouched(cocos2d::extension::CCTableView* table, cocos2d::extension::CCTableViewCell* cell);
//定制每个cell的size
virtual cocos2d::CCSize tableCellSizeForIndex(cocos2d::extension::CCTableView *table, unsigned int idx);
//定制每个cell的内容
virtual cocos2d::extension::CCTableViewCell* tableCellAtIndex(cocos2d::extension::CCTableView *table, unsigned int idx);
//确定这个tableview的cell行数
virtual unsigned int numberOfCellsInTableView(cocos2d::extension::CCTableView *table);
选择实现:
//设置单元格高亮的状态
virtual void tableCellHighlight(CCTableView* table, CCTableViewCell* cell);
//设置单元格非高亮的状态
virtual void tableCellUnhighlight(CCTableView* table, CCTableViewCell* cell);
必须实现:
//由于CCTableView是继承CCScrollView,所以要继承这两个方法
virtual void scrollViewDidScroll(cocos2d::extension::CCScrollView* view) {}
virtual void scrollViewDidZoom(cocos2d::extension::CCScrollView* view) {}
下面介绍实现方法。
1。使用的时候要注意要引入扩展库文件: #include &cocos-ext.h& ,并且最好要添加: USING_NS_CC_EXT ; 这样就不用老是加前缀cocos2d::extension。
2。要继承CCTableView的两个代理 CCTableViewDelegate 和 CCTableViewDataSource。比如:
class HelloWorld : public cocos2d::CCLayer,public cocos2d::extension::CCTableViewDelegate,public cocos2d::extension::CCTableViewDataSource{
3。实现需要的方法(上述列举的三类中, 其中两类必须实现。 还有一类可选。)
简单三不,就能定制属于你自己的列表了。很简单吧。
下面给出上述天天酷跑道具列表的实现代码。
GameInfo.h
GameInfo.h
Created by 余龙泽 on 14-3-28.
#ifndef __RunGame__GameInfo__
#define __RunGame__GameInfo__
#include &iostream&
#include &cocos2d.h&
#include &cocos-ext.h&
USING_NS_CC_EXT;//cocos2dx定义的宏
using namespace cocos2d;
class GameInfo : public cocos2d::CCLayer,public cocos2d::extension::CCTableViewDelegate,cocos2d::extension::CCTableViewDataSource
virtual bool init();
static cocos2d::CCScene* scene();
void menuCloseCallback(CCObject* pSender);
//CCTableViewDelegate继承自CCScrollViewDelegate
virtual void scrollViewDidScroll(cocos2d::extension::CCScrollView* view);
virtual void scrollViewDidZoom(cocos2d::extension::CCScrollView* view);
//点击哪个cell
virtual void tableCellTouched(cocos2d::extension::CCTableView* table, cocos2d::extension::CCTableViewCell* cell);
//每个cell的size
virtual cocos2d::CCSize cellSizeForTable(cocos2d::extension::CCTableView *table);
//生成cell
virtual cocos2d::extension::CCTableViewCell* tableCellAtIndex(cocos2d::extension::CCTableView *table, unsigned int idx);
//cell的数量
virtual unsigned int numberOfCellsInTableView(cocos2d::extension::CCTableView *table);
//按下去的时候,就是高亮显示,这里可以设置高亮状态
virtual void tableCellHighlight(cocos2d::extension::CCTableView* table, cocos2d::extension::CCTableViewCell* cell);
//松开的时候,取消高亮状态
virtual void tableCellUnhighlight(cocos2d::extension::CCTableView* table, cocos2d::extension::CCTableViewCell* cell);
void scrollBar(cocos2d::extension::CCTableView* table);
CREATE_FUNC(GameInfo);
#endif /* defined(__RunGame__GameInfo__) */
GameInfo.cpp
GameInfo.cpp
Created by 余龙泽 on 14-3-28.
#include &GameInfo.h&
#include &SimpleAudioEngine.h&
using namespace cocos2d;
using namespace CocosD
CCScene* GameInfo::scene()
CCScene *scene = CCScene::create();
GameInfo *layer = GameInfo::create();
scene-&addChild(layer);
bool GameInfo::init()
if ( !CCLayer::init() )
//获取屏幕大小
CCSize visibSize=CCDirector::sharedDirector()-&getVisibleSize();
//设置背景
CCSprite *bg_ = CCSprite::create(&pic_InfoBg.png&);
this-&setPosition(ccp(visibSize.width/2, visibSize.height/2));
this-&addChild(bg_);
//添加列表
CCTableView *tableView=CCTableView::create(this, CCSizeMake(620, 450));
tableView-&setDirection(kCCScrollViewDirectionVertical);
tableView-&setPosition(ccp(-525, -275));
tableView-&setAnchorPoint(ccp(0, 0));
tableView-&setDelegate(this);
tableView-&setVerticalFillOrder(kCCTableViewFillTopDown);
this-&addChild(tableView,1);
tableView-&reloadData();
void GameInfo::menuCloseCallback(CCObject* pSender)
CCDirector::sharedDirector()-&end();
#if (CC_TARGET_PLATFORM == CC_PLATFORM_IOS)
//cell的数量
unsigned int GameInfo::numberOfCellsInTableView(CCTableView *table)
//生成cell
CCTableViewCell* GameInfo::tableCellAtIndex(CCTableView *table, unsigned int idx)
CCString *nameString=CCString::createWithFormat(&cell_%d.png&,idx);
CCTableViewCell *cell = table-&dequeueCell();
if (!cell)
cell = new CCTableViewCell();
cell-&autorelease();
//设置当前cell图片
CCSprite *iconSprite = CCSprite::create(nameString-&getCString());
iconSprite-&setAnchorPoint(CCPointZero);
iconSprite-&setPosition(ccp(0, 0));
iconSprite-&setTag(123);
cell-&addChild(iconSprite);
//创建了就不需要再重新创建了,不然你会发现图片跟文字都不对
CCTexture2D *aTexture=CCTextureCache::sharedTextureCache()-&addImage(nameString-&getCString());
CCSprite *pSprite=(CCSprite *)cell-&getChildByTag(123);
pSprite-&setTexture(aTexture);
CCSize GameInfo::cellSizeForTable(CCTableView *table)
return CCSizeMake(605, 105);
void GameInfo::tableCellHighlight(CCTableView *table, CCTableViewCell *cell)
void GameInfo::tableCellUnhighlight(CCTableView *table, CCTableViewCell *cell)
void GameInfo::tableCellTouched(CCTableView *table, CCTableViewCell *cell)
CCBlink *blink_ = CCBlink::create(1.0f, 7);
cell-&runAction(blink_);
void GameInfo::scrollViewDidScroll(cocos2d::extension::CCScrollView *view)
void GameInfo::scrollViewDidZoom(cocos2d::extension::CCScrollView *view)
写到这里,基本差不多了。
如果需要上述demo的话.可以留下邮箱我单独发送。
学习的路上,与君共勉。
已发表评论数()
&&登&&&陆&&}

我要回帖

更多关于 坐骑天下 的文章

更多推荐

版权声明:文章内容来源于网络,版权归原作者所有,如有侵权请点击这里与我们联系,我们将及时删除。

点击添加站长微信