• 博客园logo
  • 会员
  • 周边
  • 新闻
  • 博问
  • 闪存
  • 众包
  • 赞助商
  • Chat2DB
    • 搜索
      所有博客
    • 搜索
      当前博客
  • 写随笔 我的博客 短消息 简洁模式
    用户头像
    我的博客 我的园子 账号设置 会员中心 简洁模式 ... 退出登录
    注册 登录

chchpd

  • 博客园
  • 联系
  • 订阅
  • 管理

公告

随笔分类 -  cocos2dx

cocos2dx开发
cocos2dx --- Action介绍 (二)
摘要:有时需要指定在某一个时刻有谁执行某个动作,此时就有必要使用CCActionInstant继承树中一类特殊的类,即CCCallFunc家族。 CCCallFunc家族主要有四个类: 1 CCCallFunc *CCCallFunc::actionWithTarget(SelectorProtocol* pSelectorTarget,SEL_CallFunc selector); 2 CCCallFuncN *CCCallFuncN::actionWithTarget(SelectorProtocol* pSelectorTarget,SEL_CallFuncN selector)... 阅读全文

posted @ 2013-05-15 16:30 chchpd 阅读(322) 评论(0) 推荐(0)

cocos2dx --- Touch (二)
摘要:本文是关于cocos2dx获取并进行处理Android的滑屏事件,实现一个动态壁纸的效果。关于Android的本身的滑屏处理不在本文范围内。 在Android层面需要继承XXXWallPaperService,并实现onOffesetsChanged方法,当然为了使得cocos2dx获取onOffsetsChaneged事件,需要额外定义JNI接口,通过JNI接口,实现Cocos2dx的动态滑屏效果。 实现: 1).JNI接口(Java,C++) 1 public class ClassName implements GLWallpaperService.Renderer { 2 ... 阅读全文

posted @ 2013-05-15 13:59 chchpd 阅读(510) 评论(0) 推荐(0)

cocos2dx --- anchor point
摘要:在做物体的旋转的时候,遇到此问题。那么怎么理解AnchorPoint?1.sprite之Anchor Point 特性: 1).anchor是一个CGPOINT,取值在(0.0f, 0,0f) 到 (1.0f, 1.0f)之间。 2).(0.0f, 0.0f)是这个CCSprite矩形区域的左下角,(1.0f, 1.0f)是右上角。 3).anchor决定了这个sprite的position指的是图片中哪个部分的位置,比如anchor在(0.0f, 0.0f),position在(100, 100),则这个sprite的左下角将被放在(100, 100)。 4).anchor决定对这个... 阅读全文

posted @ 2013-05-09 16:08 chchpd 阅读(380) 评论(0) 推荐(0)

cocos2dx --- Action综合应用三:曲线Action
摘要:在学习上两篇博文的基础上,做了一个可以曲线Action。当然基于此可以结合傅里叶变换和欧拉变换做出更炫的效果思路:基本三角函数变换实现: 1.CurveMove头文件 1 class CC_DLL CCCurveMove : public CCActionInterval 2 { 3 public: 4 /** initializes the action */ 5 bool initWithDuration(float duration, const CCPoint& position,float scaleX,float period); 6 virtual CC... 阅读全文

posted @ 2013-05-09 15:39 chchpd 阅读(560) 评论(0) 推荐(0)

cocos2dx --- Action介绍 (一)
摘要:部分转载自:http://blog.csdn.net/qiurisuixiang/article/details/87737971. cocos2dx中,CCAction的类的结构图2.动作的基类是CCAction,通过继承它可以实现很多不同的动作,主要分为三大类:CCFiniteTimeAction(有限次动作执行类)、CCSpeed(节点执行速度类)、CCFollow(节点跟随另一个节点移动)。在实际中,主要用到的是CCFiniteTimeAction类。3.CCFiniteTimeAction分为CCActionInstant(瞬时动作)和CCActionInterval(延迟动作)。其 阅读全文

posted @ 2013-05-07 18:17 chchpd 阅读(2033) 评论(0) 推荐(0)

cocos2dx --- Action综合应用二:椭圆运动Action
摘要:转载:http://blog.csdn.net/ufolr/article/details/7447773ufolr cocos2dx中提供了一些常用的action,但有时为了实现某种特效,需要定义自己的Action。这篇博文展现了通过继承CCActionInterval实现了椭圆运动Action。大家可以根据ufolr博主的思想,举一反三实现自己的Action。 思路:根据椭圆方程(在实现当中尽量用参数方程,避免复杂平方的计算),在每一帧中更新Sprite的位置 实现:确定一个椭圆的条件,需要知道空间位置(中心点坐标)、长半轴(a)、和短半轴(b)(或者知道半焦距(c))。因此需要... 阅读全文

posted @ 2013-05-07 17:04 chchpd 阅读(1068) 评论(0) 推荐(0)

cocos2dx --- Action综合应用一:落叶效果
摘要:转载:http://blog.csdn.net/ufolr/article/details/7624851 ufolr仿真感较强的立体的落叶效果思路: 落叶动作分解:下落+摆动+自转。最后同时执行。实现: 1 class Leaf : public cocos2d::CCLayer 2 { 3 public: 4 virtual bool init(); 5 6 void resetLeafPos(CCNode* sender);//叶片位置重置函数 7 void playLeafAnim(CCSprite *spriteLeaf);//下落过程实现函数 8 9 ... 阅读全文

posted @ 2013-05-07 17:03 chchpd 阅读(1400) 评论(0) 推荐(0)

cocos2dx --- draw line
摘要:1 void DrawLine::draw(){ 2 drawLine(); 3 } 4 void DrawLine::drawLine(){ 5 CCLog("DrawLayer draw line"); 6 int tickSubCount = 20; 7 int pointListKeepCount = 500; 8 for(int i=0; i<tickSubCount; ++i){ 9 if(pointList.size()>0){10 pointList.pop_front();11 ... 阅读全文

posted @ 2013-05-03 17:28 chchpd 阅读(734) 评论(0) 推荐(0)

cocos2dx --- Touch (一)
摘要:1.相关的类 CCTouch:封装了触摸点。通过getLocation()返回OpenGL coordinates下的CCpoint,或通通过getLocationInView()返回在Screen coordinates下的CCpoint CCTouchDelegate:触摸事件委托。在处理触摸事件时,必须继承该类。它封装了如下几个方法1 virtual void ccTouchesBegan(CCSet *pTouches, CCEvent *pEvent);2 virtual void ccTouchesMoved(CCSet *pTouches, CCEvent *pEvent);.. 阅读全文

posted @ 2013-05-03 17:27 chchpd 阅读(841) 评论(0) 推荐(0)

 
博客园  ©  2004-2026
浙公网安备 33010602011771号 浙ICP备2021040463号-3