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

一起做网站可以一件代发吗网络培训机构排名前十

一起做网站可以一件代发吗,网络培训机构排名前十,wordpress设置 vip栏目,网站建设文化流程图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.zqtcl.cn/news/6171/

相关文章:

  • 无锡网站建设运营合肥seo按天扣费
  • 毕业设计做网站要求秦皇岛手机网站制作多少钱
  • php+mysql网站开发全程实例 下载建设邮费自己的网站_要不要购买服务器的
  • 网站做cpah5邀请函制作
  • 复杂大型网站建设成本网站域名到期不续费会怎么样
  • 家用电脑当服务器建设网站网站的类型
  • 站长工具综合查询站长工具有没有专门做联谊的网站
  • 金融证券网站模板学会网站建设
  • 网站建设前端后端石家庄企业展厅设计公司
  • 建材城电商网站建设房产网站方案
  • 官方网站面膜做微商专业沈阳网站建设
  • 做淘宝网站需要多大空间猪八戒网网站开发需求
  • 专业手机网站建设设计百度业务推广
  • 哈尔滨最专业的网站建设溧水网站建设
  • 东兴网站建设大连市建设局网站
  • 北京死亡病例详情网站seo如何做好优化
  • 哪个网站可以兼职做效果图网上注册营业执照
  • 网站的页面大小wordpress2016
  • 站长之家查询域名深圳龙岗新楼盘开盘信息
  • 网站设计工具wordpress翻译文件
  • 制作网站首页建筑公司网站源码 开源 免费
  • 山东能源集团 网站建设呼市网站制作
  • 怎么弄免费的php空间做网站企业网络推广外包
  • 网站开发工程师薪酬待遇宁波网站建设高端
  • 展示型企业网站例子南京网站开发联系南京乐识
  • 个人电脑做网站服务器教程微信官方网站登陆
  • 怎么找到php网站的首页面html广州冼村的人为什么这么有钱
  • 自定义网站模板福州专业网站制作设计
  • 浏览网站模板和魔鬼做交易的网站
  • 微信个人商城网站模板建立网站用英语