当前位置: 首页 > news >正文

扬州市网站建设_网站建设公司_Ruby_seo优化

湖北建设监理协会网站,怎样简单做网站,手机在线作图软件,app网站开发合同cocos2dx中有三种定时器#xff1a;schedule#xff0c;scheduleUpdate#xff0c;scheduleOnce。功能分别是 每隔几秒调用自定义函数、调用系统默认的update()函数、只调用一次自定义函数 1、scheduleUpdate 加入当前节点后#xff0c;程序会每帧都会自动执行一次默认的…cocos2dx中有三种定时器schedulescheduleUpdatescheduleOnce。功能分别是 每隔几秒调用自定义函数、调用系统默认的update()函数、只调用一次自定义函数 1、scheduleUpdate 加入当前节点后程序会每帧都会自动执行一次默认的Update函数。注一定是Update函数哦若想调用其他自己命名的函数则使用schedule 看例子走起。 首先在HelloWord类的头文件中声明Update函数 void Update(float dt); //注意参数类型然后在HelloWorld类源文件中实现函数Update voidHelloWorld::Update(float dt) { CCLOG(baibai);} 现在我们可以调用了在需要他不断执行的地方加入调用的代码就ok this-scheduleUpdate(); //this是当前节点如layer所以可以省略啦。运行之后你将会看到不断有baibai被打印出来 停止方法 this-unscheduleUpdate(); 2、schedule 功能每隔几秒执行一次函数 首先还是在HelloWorld中声明所要执行的函数 void Move(float dt);然后在源文件实现 void HelloWorld::Move(floatdt) { CCLOG(baibai);} 现在去执行他注意参数哦 this-schedule(schedule_selector(HelloWorld::Move),1.0f); //每隔1.0f执行一次省略参数则表示每帧都要执行运行之后baibai每隔1.0f才会被打印一次。 停止方法 this-unschedule(schedule_selector(HelloWorld::Move)); 3、scheduleOnce 功能在几秒之后执行并且只会执行一次。 我们就执行上面所写的Move函数吧。 this-scheduleOnce(schedule_selector(HelloWorld::Move),1.0f); //在1.0f之后执行并且只执行一次。 运行一下baibai只是被打印了一次就完了。。。 ok定时器的调用已经讲完了大家不妨自己写一些函数体验一下。 4、停止所有计时器 this-unscheduleAllSelectors() CCNode类的setPositiongetPosition函数如果是一个Node的Child则获取的坐标就是该Node的本地坐标 另一个关键问题就是在cocos2d-x里就是各种对象的大小问题。因为在cocos2d-x里CCNode对象有缩放的方法setScaleX和setScaleY。所以在获取对象大小的时候必须根据情况明确指定获取对象原始大小还是缩放后的大小。当然cocos2d-x里提供了对应函数来完成这些操作 getContentSize函数来获得节点原始的大小。只是逻辑尺寸不是像素 boundingBox函数来获得经过缩放和旋转之后的外框盒大小。 getContentSizeInPixels获得的是像素点大小 像素点和逻辑点关系逻辑点大小 像素大小 getVisibleSize默示获得视口可视区域的大小若是DesignResolutionSize跟屏幕尺寸一样大则getVisibleSize便是getWinSize。 getVisibleOrigin默示可视区域的出发点坐标这在处理惩罚相对地位的时辰很是有效确保节点在不合辨别率下的地位一致。 坐标转换 GL坐标系cocos2d-x默认坐标系 CCPoint CCDirector::convertToGL(const CCPoint uiPoint) { CCSize s m_obWinSizeInPoints; float newY s.height - uiPoint.y; } 屏幕坐标系 默认原点在左上角 CCPoint CCDirector::convertToUI(const CCPoint glPoint) { CCSize winSize m_obWinSizeInPoints; float oppositeY winSize.height - glPoint.y; return ccp(glPoint.x,oppositeY);} 两种坐标的X方向没有变只变了Y方向cocos2d-x里默认的GL坐标系即左下角为原点ccp(0.0f,0.0f) // 创建精灵的五种方法 //方法一直接创建精灵 //适合于要显示的是这张图片的全部区域 CCSprite * sprite CCSprite::create(Icon.png); //上面那句话也可以根据需要这样来写 //CCString* fileName CCString::createWithFormat(Icon_%d.jpg, flag); //CCSprite* sprite CCSprite::create(fileName-getCString()); sprite-setPosition(ccp(100, 100)); this-addChild(sprite); // 方法二参数 图片名称 矩形区域 //适合于需要显示此图片的部分区域 CCSprite * sprite CCSprite::create(Icon.png,CCRectMake(0, 0, 30, 30)); sprite-setPosition(ccp(100, 100)); this-addChild(sprite); //方法三 利用帧缓存中的一帧的名称声称一个对象 // 适合于plist打包好的文件 CCSpriteFrameCache::sharedSpriteFrameCache()-addSpriteFramesWithFile(test_icon.plist); CCSprite * sprite CCSprite::createWithSpriteFrameName(Icon.png); sprite-setPosition(ccp(100, 100)); this-addChild(sprite); //方法四 利用另外一帧生成一个精灵对象 //适合于做帧动画使用 CCSpriteFrame * frame CCSpriteFrame::create(Icon.png, CCRectMake(0, 0, 40, 30)); CCSprite * sprite CCSprite::createWithSpriteFrame(frame); sprite-setPosition(ccp(310, 150)); addChild(sprite); //方法五利用纹理 //适合于需要频繁使用的图片 CCSpriteBatchNode* spriteTexture CCSpriteBatchNode::create(iocn.png); spriteTexture-setPosition(CCPointZero); addChild(spriteTexture); CCSprite* sprite CCSprite::createWithTexture(spriteTexture-getTexture()); sprite-setPosition(ccp(visiblesize.width/2, 100)); spriteTexture-addChild(sprite, 2); 常用的封装方法 //返回场景 static CCScene* scene(CCLayer*layer){CCScene *sceneCCScene::create();scene-addChild(layer);//scene-autorelease();return scene;} //移动点static void moveNode(CCNode *node,CCPoint point){node-setPosition(node-getPosition()point);} //格式化串接字符串static char* format(int v, const char* prefix , const char* suffix ){static char buf[2048];sprintf(buf, %s%d%s, prefix, v, suffix);return buf;} //创建动画static CCAnimation* CreateAnimation(const char* filename,int start,int end,int width,float delay){CCTexture2D *textureCCTextureCache::sharedTextureCache()-addImage(filename);CCArray *arrayCCArray::create();for (int istart;iend;i){CCSpriteFrame *frameCCSpriteFrame::createWithTexture(texture,CCRectMake(i*width,0,width,texture-getContentSize().height));array-addObject(frame);}return CCAnimation::createWithSpriteFrames(array,delay);} //创建帧static CCSpriteFrame* getSpriteFrame(const char* filename, int pos, int width){CCTexture2D* texture CCTextureCache::sharedTextureCache()-addImage(filename);CCSpriteFrame* frame CCSpriteFrame::createWithTexture(texture, CCRectMake(pos*width, 0, width, texture-getContentSize().height));return frame;}//地图坐标转格子地图static CCPoint Point2Tile(CCTMXTiledMap* map, CCPoint ptInMap){int dx map-getTileSize().width;int dy map-getTileSize().height;int x ptInMap.x / dx;int y ptInMap.y / dy;y map-getMapSize().height - 1 - y;return ccp(x, y);} //格子地图坐标转地图坐标static CCPoint Tile2PointLB(CCTMXTiledMap* map, CCPoint ptTile){ptTile.y map-getMapSize().height - 1 - ptTile.y;return ccp(ptTile.x * map-getTileSize().width,ptTile.y * map-getTileSize().height);}
http://www.ihoyoo.com/news/49160.html

相关文章:

  • 做网站最简单wordpress远程上传媒体文件
  • 肥城网站网站建设企业手机网站 案例
  • 学校网站源码免费怎么做淘宝客的网站
  • 网站域名dns自己的身份已经网站备案了
  • 电烤箱做蛋糕网站深圳做网站公司地点
  • 南昌网站建设58软件工程师考试
  • 华为云做的网站怎么样平面设计画册设计
  • 做网站的设计尺寸个人网站制作模板主页
  • 公众号的微网站怎么做中药材天地网做中药零售网站
  • 镇江网站建设镇江天津市建设工程质量协会网站
  • 响应式网站好不好wordpress手机发布文章
  • 山东电商网站建设asp静态网站源码
  • 中文域名查询网站appserv wordpress
  • 玉林住房和建设厅网站佛山网站排名优化
  • 网站的数据库丢失上海 网站设计
  • 鹤壁专业做网站公司绍兴网站制作价格
  • 跳转到手机网站代码南头做网站公司
  • 网站正在建设升级网站建设评审验收会议主持词
  • 网站怎么做营销网站管理员有哪些权限
  • 网站运营写营销莱芜区平台公司
  • 教育机构做网站的目的第一ppt网免费模板
  • 做外贸有免费的网站吗app界面设计网站
  • 购物网站seo搜索引擎优化方案影视公司起名
  • 企业怎么建设网站首页注册贸易公司需要什么条件
  • 宜昌电子商城网站建设泰州网络科技有限公司
  • 博达网站建设怎么建立下载网站改版需要向百度000提交吗
  • 丹江口网站开发南昌seo专业团队
  • 网站建设培训班多少钱郑州大学现代远程教育 《网页设计与网站建设》个人主页
  • 织梦企业网站源码做旅游网站的
  • 做张家界旅游网站多少钱网站后台登陆验证码不对