这篇教程C++ CC_RECT_PIXELS_TO_POINTS函数代码示例写得很实用,希望能帮到您。
本文整理汇总了C++中CC_RECT_PIXELS_TO_POINTS函数的典型用法代码示例。如果您正苦于以下问题:C++ CC_RECT_PIXELS_TO_POINTS函数的具体用法?C++ CC_RECT_PIXELS_TO_POINTS怎么用?C++ CC_RECT_PIXELS_TO_POINTS使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。 在下文中一共展示了CC_RECT_PIXELS_TO_POINTS函数的22个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。 示例1: CCAssert// CCTMXLayer - obtaining tiles/gidsCCSprite * CCTMXLayer::tileAt(const CCPoint& pos){ CCAssert( pos.x < m_tLayerSize.width && pos.y < m_tLayerSize.height && pos.x >=0 && pos.y >=0, "TMXLayer: invalid position"); CCAssert( m_pTiles && m_pAtlasIndexArray, "TMXLayer: the tiles map has been released"); CCSprite *tile = NULL; unsigned int gid = this->tileGIDAt(pos); // if GID == 0, then no tile is present if( gid ) { int z = (int)(pos.x + pos.y * m_tLayerSize.width); tile = (CCSprite*) this->getChildByTag(z); // tile not created yet. create it if( ! tile ) { CCRect rect = m_pTileSet->rectForGID(gid); rect = CC_RECT_PIXELS_TO_POINTS(rect); tile = new CCSprite(); tile->initWithTexture(this->getTexture(), rect); tile->setBatchNode(this); tile->setPosition(positionAt(pos)); tile->setVertexZ((float)vertexZForPos(pos)); tile->setAnchorPoint(CCPointZero); tile->setOpacity(m_cOpacity); unsigned int indexForZ = atlasIndexForExistantZ(z); this->addSpriteWithoutQuad(tile, indexForZ, z); tile->release(); } } return tile;}
开发者ID:csdnnet,项目名称:hiygame,代码行数:36,
示例2: CC_RECT_PIXELS_TO_POINTS// used only when parsing the map. useless after the map was parsed// since lot's of assumptions are no longer trueSprite * TMXLayer::appendTileForGID(int gid, const Point& pos){ if (gid != 0 && (static_cast<int>((gid & kFlippedMask)) - _tileSet->_firstGid) >= 0) { Rect rect = _tileSet->rectForGID(gid); rect = CC_RECT_PIXELS_TO_POINTS(rect); intptr_t z = (intptr_t)(pos.x + pos.y * _layerSize.width); Sprite *tile = reusedTileWithRect(rect); setupTileSprite(tile ,pos ,gid); // optimization: // The difference between appendTileForGID and insertTileforGID is that append is faster, since // it appends the tile at the end of the texture atlas ssize_t indexForZ = _atlasIndexArray->num; // don't add it using the "standard" way. insertQuadFromSprite(tile, indexForZ); // append should be after addQuadFromSprite since it modifies the quantity values ccCArrayInsertValueAtIndex(_atlasIndexArray, (void*)z, indexForZ); return tile; } return nullptr;}
开发者ID:lache,项目名称:anyang,代码行数:31,
示例3: CCASSERT// TMXLayer - obtaining tiles/gidsSprite * TMXLayer::getTileAt(const Point& pos){ CCASSERT(pos.x < _layerSize.width && pos.y < _layerSize.height && pos.x >=0 && pos.y >=0, "TMXLayer: invalid position"); CCASSERT(_tiles && _atlasIndexArray, "TMXLayer: the tiles map has been released"); Sprite *tile = nullptr; int gid = this->getTileGIDAt(pos); // if GID == 0, then no tile is present if (gid) { int z = (int)(pos.x + pos.y * _layerSize.width); tile = static_cast<Sprite*>(this->getChildByTag(z)); // tile not created yet. create it if (! tile) { Rect rect = _tileSet->rectForGID(gid); rect = CC_RECT_PIXELS_TO_POINTS(rect); tile = Sprite::createWithTexture(this->getTexture(), rect); tile->setBatchNode(this); tile->setPosition(getPositionAt(pos)); tile->setVertexZ((float)getVertexZForPos(pos)); tile->setAnchorPoint(Point::ZERO); tile->setOpacity(_opacity); ssize_t indexForZ = atlasIndexForExistantZ(z); this->addSpriteWithoutQuad(tile, static_cast<int>(indexForZ), z); } } return tile;}
开发者ID:lache,项目名称:anyang,代码行数:35,
示例4: CC_RECT_PIXELS_TO_POINTSvoid Factory::initSpriteFrame(){ auto texture = Director::getInstance()->getTextureCache()->addImage("Monster.png"); monsterDead.reserve(4); for (int i = 0; i < 4; i++) { auto frame = SpriteFrame::createWithTexture(texture, CC_RECT_PIXELS_TO_POINTS(Rect(258-48*i,0,42,42))); monsterDead.pushBack(frame); }}
开发者ID:MoHuaxiao,项目名称:Cocos2d-Game,代码行数:8,
示例5: CC_RECT_PIXELS_TO_POINTScocos2d::Animation * BaseSprite::createAnimation(const char* formatStr, float width, float height, int frameCount, float f){ cocos2d::Vector<SpriteFrame*> frames; frames.reserve(frameCount); auto texture = Director::getInstance()->getTextureCache()->addImage(formatStr); width = width / frameCount; for (int i = 0; i < frameCount; i++) { auto frame = SpriteFrame::createWithTexture(texture, CC_RECT_PIXELS_TO_POINTS(Rect(width * i, 0, width, height))); frames.pushBack(frame); } return Animation::createWithSpriteFrames(frames, f);}
开发者ID:CrayonQ7,项目名称:FightGame,代码行数:13,
示例6: CC_RECT_PIXELS_TO_POINTSbool CCSpriteFrame::initWithTextureFilename(const char* filename, const CCRect& rect, bool rotated, const CCPoint& offset, const CCSize& originalSize){ m_pobTexture = NULL; m_strTextureFilename = filename; m_obRectInPixels = rect; m_obRect = CC_RECT_PIXELS_TO_POINTS( rect ); m_obOffsetInPixels = offset; m_obOffset = CC_POINT_PIXELS_TO_POINTS( m_obOffsetInPixels ); m_obOriginalSizeInPixels = originalSize; m_obOriginalSize = CC_SIZE_PIXELS_TO_POINTS( m_obOriginalSizeInPixels ); m_bRotated = rotated; return true;}
开发者ID:boruis,项目名称:cocos2dx-classical,代码行数:14,
示例7: CC_RECT_PIXELS_TO_POINTSbool SpriteFrame::initWithTextureFilename(const std::string& filename, const Rect& rect, bool rotated, const Vec2& offset, const Size& originalSize){ _texture = nullptr; _textureFilename = filename; _rectInPixels = rect; _rect = CC_RECT_PIXELS_TO_POINTS( rect ); _offsetInPixels = offset; _offset = CC_POINT_PIXELS_TO_POINTS( _offsetInPixels ); _originalSizeInPixels = originalSize; _originalSize = CC_SIZE_PIXELS_TO_POINTS( _originalSizeInPixels ); _rotated = rotated; return true;}
开发者ID:skatpgusskat,项目名称:December,代码行数:14,
示例8: CC_RECT_PIXELS_TO_POINTSbool SpriteFrame::initWithTextureFilename(const char* filename, const Rect& rect, bool rotated, const Point& offset, const Size& originalSize){ _texture = NULL; _textureFilename = filename; _rectInPixels = rect; _rect = CC_RECT_PIXELS_TO_POINTS( rect ); _offsetInPixels = offset; _offset = CC_POINT_PIXELS_TO_POINTS( _offsetInPixels ); _originalSizeInPixels = originalSize; _originalSize = CC_SIZE_PIXELS_TO_POINTS( _originalSizeInPixels ); _rotated = rotated; return true;}
开发者ID:ADoby,项目名称:Project_Space_Pirate,代码行数:14,
示例9: CCASSERTvoid TMXLayer::setTileGID(int gid, const Vec2& tileCoordinate, TMXTileFlags flags){ CCASSERT(tileCoordinate.x < _layerSize.width && tileCoordinate.y < _layerSize.height && tileCoordinate.x >=0 && tileCoordinate.y >=0, "TMXLayer: invalid position"); CCASSERT(_tiles, "TMXLayer: the tiles map has been released"); CCASSERT(gid == 0 || gid >= _tileSet->_firstGid, "TMXLayer: invalid gid" ); TMXTileFlags currentFlags; int currentGID = getTileGIDAt(tileCoordinate, ¤tFlags); if (currentGID == gid && currentFlags == flags) return; int gidAndFlags = gid | flags; // setting gid=0 is equal to remove the tile if (gid == 0) { removeTileAt(tileCoordinate); } // empty tile. create a new one else if (currentGID == 0) { int z = tileCoordinate.x + tileCoordinate.y * _layerSize.width; setFlaggedTileGIDByIndex(z, gidAndFlags); } // modifying an existing tile with a non-empty tile else { int z = tileCoordinate.x + tileCoordinate.y * _layerSize.width; auto it = _spriteContainer.find(z); if (it != _spriteContainer.end()) { Sprite *sprite = it->second.first; Rect rect = _tileSet->getRectForGID(gid); rect = CC_RECT_PIXELS_TO_POINTS(rect); sprite->setTextureRect(rect, false, rect.size); this->reorderChild(sprite, z); if (flags) { setupTileSprite(sprite, sprite->getPosition(), gidAndFlags); } it->second.second = gidAndFlags; } else { setFlaggedTileGIDByIndex(z, gidAndFlags); } }}
开发者ID:keith1020,项目名称:cocos.github.io,代码行数:50,
示例10: CC_RECT_PIXELS_TO_POINTSvoid CCSprite::setTextureRectInPixels(CGRect rect, bool rotated, CGSize size){ m_obRectInPixels = rect; m_obRect = CC_RECT_PIXELS_TO_POINTS(rect); m_bRectRotated = rotated; setContentSizeInPixels(size); updateTextureCoords(m_obRectInPixels); CGPoint relativeOffsetInPixels = m_obUnflippedOffsetPositionFromCenter; // issue #732 if (m_bFlipX) { relativeOffsetInPixels.x = -relativeOffsetInPixels.x; } if (m_bFlipY) { relativeOffsetInPixels.y = -relativeOffsetInPixels.y; } m_obOffsetPositionInPixels.x = relativeOffsetInPixels.x + (m_tContentSizeInPixels.width - m_obRectInPixels.size.width) / 2; m_obOffsetPositionInPixels.y = relativeOffsetInPixels.y + (m_tContentSizeInPixels.height - m_obRectInPixels.size.height) / 2; // rendering using SpriteSheet if (m_bUsesBatchNode) { // update dirty_, don't update recursiveDirty_ m_bDirty = true; } else { // self rendering // Atlas: Vertex float x1 = 0 + m_obOffsetPositionInPixels.x; float y1 = 0 + m_obOffsetPositionInPixels.y; float x2 = x1 + m_obRectInPixels.size.width; float y2 = y1 + m_obRectInPixels.size.height; // Don't update Z. m_sQuad.bl.vertices = vertex3(x1, y1, 0); m_sQuad.br.vertices = vertex3(x2, y1, 0); m_sQuad.tl.vertices = vertex3(x1, y2, 0); m_sQuad.tr.vertices = vertex3(x2, y2, 0); }}
开发者ID:valentinvit,项目名称:cocos2d-x,代码行数:47,
示例11: CC_RECT_PIXELS_TO_POINTSbool SpriteFrame::initWithTextureFilename(const std::string& filename, const Rect& rect, bool rotated, const Vec2& offset, const Size& originalSize){ if (FileUtils::getInstance()->isFileExist(filename)) { _texture = nullptr; _textureFilename = filename; _rectInPixels = rect; _rect = CC_RECT_PIXELS_TO_POINTS( rect ); _offsetInPixels = offset; _offset = CC_POINT_PIXELS_TO_POINTS( _offsetInPixels ); _originalSizeInPixels = originalSize; _originalSize = CC_SIZE_PIXELS_TO_POINTS( _originalSizeInPixels ); _rotated = rotated; _anchorPoint = Vec2(NAN, NAN); _centerRect = Rect(NAN, NAN, NAN, NAN); return true; } return false;}
开发者ID:hugohuang1111,项目名称:Bird,代码行数:18,
示例12: CC_RECT_PIXELS_TO_POINTSbool CCSpriteFrame::initWithTexture(CCTexture2D* pobTexture, CCRect rect, bool rotated, CCPoint offset, CCSize originalSize){ m_pobTexture = pobTexture; if (pobTexture) { pobTexture->retain(); } m_obRectInPixels = rect; m_obRect = CC_RECT_PIXELS_TO_POINTS(rect); m_bRotated = rotated; m_obOffsetInPixels = offset; m_obOriginalSizeInPixels = originalSize; return true;}
开发者ID:MySure,项目名称:Test,代码行数:18,
示例13: CC_SAFE_RETAINbool CCSpriteFrame::initWithTexture(CCTexture2D* pobTexture, const CCRect& rect, bool rotated, const CCPoint& offset, const CCSize& originalSize){ m_pobTexture = pobTexture; if (pobTexture) { CC_SAFE_RETAIN(pobTexture); } m_obRectInPixels = rect; m_obRect = CC_RECT_PIXELS_TO_POINTS(rect); m_obOffsetInPixels = offset; m_obOffset = CC_POINT_PIXELS_TO_POINTS( m_obOffsetInPixels ); m_obOriginalSizeInPixels = originalSize; m_obOriginalSize = CC_SIZE_PIXELS_TO_POINTS( m_obOriginalSizeInPixels ); m_bRotated = rotated; return true;}
开发者ID:boruis,项目名称:cocos2dx-classical,代码行数:19,
示例14: CC_RECT_PIXELS_TO_POINTS// CCTMXLayer - adding helper methodsCCSprite * CCTMXLayer::insertTileForGID(unsigned int gid, const CCPoint& pos){ CCRect rect = m_pTileSet->rectForGID(gid); rect = CC_RECT_PIXELS_TO_POINTS(rect); intptr_t z = (intptr_t)(pos.x + pos.y * m_tLayerSize.width); // if quad optimization is used CCSprite *tile; if(m_pAtlasIndexArray) { tile = reusedTileWithRect(rect); setupTileSprite(tile, pos, gid); // get atlas index unsigned int indexForZ = atlasIndexForNewZ(z); // Optimization: add the quad without adding a child this->insertQuadFromSprite(tile, indexForZ); // insert it into the local atlasindex array ccCArrayInsertValueAtIndex(m_pAtlasIndexArray, (void*)z, indexForZ); // update possible children if (m_pChildren && m_pChildren->count()>0) { CCObject* pObject = NULL; CCARRAY_FOREACH(m_pChildren, pObject) { CCSprite* pChild = (CCSprite*) pObject; if (pChild) { unsigned int ai = pChild->getAtlasIndex(); if ( ai >= indexForZ ) { pChild->setAtlasIndex(ai+1); } } } }
开发者ID:blufiro,项目名称:cocos2d-x,代码行数:42,
示例15: CC_RECT_PIXELS_TO_POINTSbool Enemy::init(){ bool ret = false; do { auto texture = Director::getInstance()->getTextureCache()->addImage("Enemy_walk.png"); auto frame0 = SpriteFrame::createWithTexture(texture, CC_RECT_PIXELS_TO_POINTS(Rect(0, 0, 114, 110))); CC_BREAK_IF(!this->initWithSpriteFrame(frame0)); Animation* idleAnim = this->createAnimation("Enemy_idle.png", 206, 100, 2, 0.3); this->setIdleAction(RepeatForever::create(Animate::create(idleAnim))); Animation* walkAnim = this->createAnimation("Enemy_walk.png", 412, 100, 4, 0.1); this->setWalkAction(RepeatForever::create(Animate::create(walkAnim))); Animation* attackAnim = this->createAnimation("Enemy_attack.png", 515, 100, 5, 0.08); this->setAttackAction(Sequence::create(Animate::create(attackAnim), BaseSprite::createIdleCallbackFunc(), NULL)); Animation* hurtAnim = this->createAnimation("Enemy_idle.png", 228, 110, 2, 0.3); // 因为没有图,所以还没实现 this->setHurtAction(Sequence::create(Animate::create(hurtAnim), BaseSprite::createIdleCallbackFunc(), NULL)); Animation* deadAnim = this->createAnimation("Enemy_idle.png", 228, 110, 2, 0.3); // 因为没有图,所以还没实现 this->setDeadAction(Sequence::create(Animate::create(deadAnim), Blink::create(3, 9), NULL)); ret = true; } while (0); return ret;}
开发者ID:CrayonQ7,项目名称:FightGame,代码行数:22,
示例16: CC_RECT_PIXELS_TO_POINTS// used only when parsing the map. useless after the map was parsed// since lot's of assumptions are no longer trueSprite * TMXLayer::appendTileForGID(uint32_t gid, const Vec2& pos){ if (gid != 0 && (static_cast<int>((gid & kTMXFlippedMask)) - _tileSet->_firstGid) >= 0) { Rect rect = _tileSet->getRectForGID(gid); rect = CC_RECT_PIXELS_TO_POINTS(rect); // Z could be just an integer that gets incremented each time it is called. // but that wouldn't work on layers with empty tiles. // and it is IMPORTANT that Z returns an unique and bigger number than the previous one. // since _atlasIndexArray must be ordered because `bsearch` is used to find the GID for // a given Z. (github issue #16512) intptr_t z = getZForPos(pos); Sprite *tile = reusedTileWithRect(rect); setupTileSprite(tile ,pos ,gid); // optimization: // The difference between appendTileForGID and insertTileforGID is that append is faster, since // it appends the tile at the end of the texture atlas ssize_t indexForZ = _atlasIndexArray->num; // don't add it using the "standard" way. insertQuadFromSprite(tile, indexForZ); // append should be after addQuadFromSprite since it modifies the quantity values ccCArrayInsertValueAtIndex(_atlasIndexArray, (void*)z, indexForZ); // Validation for issue #16512 CCASSERT(_atlasIndexArray->num == 1 || _atlasIndexArray->arr[_atlasIndexArray->num-1] > _atlasIndexArray->arr[_atlasIndexArray->num-2], "Invalid z for _atlasIndexArray"); return tile; } return nullptr;}
开发者ID:FenneX,项目名称:FenneXEmptyProject,代码行数:40,
示例17: CC_RECT_PIXELS_TO_POINTS// TMXLayer - adding helper methodsSprite * TMXLayer::insertTileForGID(unsigned int gid, const Point& pos){ Rect rect = m_pTileSet->rectForGID(gid); rect = CC_RECT_PIXELS_TO_POINTS(rect); KDintptr z = (KDintptr)(pos.x + pos.y * m_tLayerSize.width); Sprite *tile = reusedTileWithRect(rect); setupTileSprite(tile, pos, gid); // get atlas index unsigned int indexForZ = atlasIndexForNewZ(z); // Optimization: add the quad without adding a child this->insertQuadFromSprite(tile, indexForZ); // insert it into the local atlasindex array ccCArrayInsertValueAtIndex(m_pAtlasIndexArray, (void*)z, indexForZ); // update possible children if (m_pChildren && m_pChildren->count()>0) { Object* pObject = nullptr; CCARRAY_FOREACH(m_pChildren, pObject) { Sprite* child = static_cast<Sprite*>(pObject); if (child) { unsigned int ai = child->getAtlasIndex(); if ( ai >= indexForZ ) { child->setAtlasIndex(ai+1); } } }
开发者ID:mcodegeeks,项目名称:OpenKODE-Framework,代码行数:37,
示例18: RectRect NinePatchImageParser::parseCapInset() const{ Rect capInsets; Vec2 horizontalLine = this->parseHorizontalMargin(); Vec2 verticalLine = this->parseVerticalMargin(); if(_isRotated) { capInsets = Rect(verticalLine.y, _imageFrame.size.height - horizontalLine.y, verticalLine.y - verticalLine.x, horizontalLine.y - horizontalLine.x); } else { capInsets = Rect(horizontalLine.x, verticalLine.x, horizontalLine.y - horizontalLine.x, verticalLine.y - verticalLine.x); } capInsets = CC_RECT_PIXELS_TO_POINTS(capInsets); return capInsets;}
开发者ID:bonlai,项目名称:3kaigame,代码行数:24,
示例19: CC_RECT_PIXELS_TO_POINTSCCRect CC3Billboard::getBoundingBoxInPixels( CCNode* pNode ){ return CC_RECT_PIXELS_TO_POINTS( pNode->boundingBox() );}
开发者ID:HerdiandKun,项目名称:cocos3d-x,代码行数:4,
示例20: boundingBoxInPixelsCCRect CCNode::boundingBox(){ CCRect ret = boundingBoxInPixels(); return CC_RECT_PIXELS_TO_POINTS(ret);}
开发者ID:BigHand,项目名称:cocos2d-x,代码行数:5,
示例21: CC_RECT_PIXELS_TO_POINTS// on "init" you need to initialize your instancebool HelloWorld::init(){ ////////////////////////////// // 1. super init first if ( !Scene::init() ) { return false; } visibleSize = Director::getInstance()->getVisibleSize(); origin = Director::getInstance()->getVisibleOrigin(); en = false; TMXTiledMap* tmx = TMXTiledMap::create("map.tmx"); tmx->setPosition(visibleSize.width / 2, visibleSize.height / 2); tmx->setAnchorPoint(Vec2(0.5, 0.5)); tmx->setScale(Director::getInstance()->getContentScaleFactor()); this->addChild(tmx, 0); //创建一张贴图 auto texture = Director::getInstance()->getTextureCache()->addImage("$lucia_2.png"); //从贴图中以像素单位切割,创建关键帧 auto frame0 = SpriteFrame::createWithTexture(texture, CC_RECT_PIXELS_TO_POINTS(Rect(0, 0, 113, 113))); //使用第一帧创建精灵 player = Sprite::createWithSpriteFrame(frame0); player->setPosition(Vec2(origin.x + visibleSize.width / 2, origin.y + visibleSize.height / 2)); addChild(player, 3); //hp条 Sprite* sp0 = Sprite::create("hp.png", CC_RECT_PIXELS_TO_POINTS(Rect(0, 320, 420, 47))); Sprite* sp = Sprite::create("hp.png", CC_RECT_PIXELS_TO_POINTS(Rect(610, 362, 4, 16))); //使用hp条设置progressBar hp = 100; pT = ProgressTimer::create(sp); pT->setScaleX(90); pT->setAnchorPoint(Vec2(0, 0)); pT->setType(ProgressTimerType::BAR); pT->setBarChangeRate(Point(1, 0)); pT->setMidpoint(Point(0, 1)); pT->setPercentage(hp); pT->setPosition(Vec2(origin.x + 14 * pT->getContentSize().width, origin.y + visibleSize.height - 2 * pT->getContentSize().height)); addChild(pT, 1); sp0->setAnchorPoint(Vec2(0, 0)); sp0->setPosition(Vec2(origin.x + pT->getContentSize().width, origin.y + visibleSize.height - sp0->getContentSize().height)); addChild(sp0, 0); // 静态动画 idle.reserve(1); idle.pushBack(frame0); // 攻击动画 attack.reserve(17); for (int i = 0; i < 17; i++) { auto frame = SpriteFrame::createWithTexture(texture, CC_RECT_PIXELS_TO_POINTS(Rect(113 * i, 0, 113, 113))); attack.pushBack(frame); } // 可以仿照攻击动画 // 死亡动画(帧数:22帧,高:90,宽:79) auto texture2 = Director::getInstance()->getTextureCache()->addImage("$lucia_dead.png"); // Todo dead.reserve(22); for (int i = 0; i < 22; ++i) { auto frame= SpriteFrame::createWithTexture(texture2, CC_RECT_PIXELS_TO_POINTS(Rect(79 * i, 0, 79, 90))); dead.pushBack(frame); } // 运动动画(帧数:8帧,高:101,宽:68) auto texture3 = Director::getInstance()->getTextureCache()->addImage("$lucia_forward.png"); // Todo run.reserve(8); for (int i = 0; i < 8; ++i) { auto frame = SpriteFrame::createWithTexture(texture3, CC_RECT_PIXELS_TO_POINTS(Rect(68 * i, 0, 68, 101))); run.pushBack(frame); } auto w = Label::createWithTTF("W", "fonts/arial.ttf", 36); auto wItem = MenuItemLabel::create(w, CC_CALLBACK_1(HelloWorld::moveWCallback,this)); wItem->setPosition(100, 100); auto s = Label::createWithTTF("S", "fonts/arial.ttf", 36); auto sItem = MenuItemLabel::create(s, CC_CALLBACK_1(HelloWorld::moveSCallback, this)); sItem->setPosition(100, 50); auto a = Label::createWithTTF("A", "fonts/arial.ttf", 36); auto aItem = MenuItemLabel::create(a, CC_CALLBACK_1(HelloWorld::moveACallback, this)); aItem->setPosition(50, 50); auto d = Label::createWithTTF("D", "fonts/arial.ttf", 36); auto dItem = MenuItemLabel::create(d, CC_CALLBACK_1(HelloWorld::moveDCallback, this)); dItem->setPosition(150, 50); auto x = Label::createWithTTF("X", "fonts/arial.ttf", 36); auto xItem = MenuItemLabel::create(x, CC_CALLBACK_1(HelloWorld::moveXCallback, this)); xItem->setPosition(visibleSize.width-50, 100); auto y = Label::createWithTTF("Y", "fonts/arial.ttf", 36);//.........这里部分代码省略.........
开发者ID:CurryYuan,项目名称:UWP-application,代码行数:101,
示例22: switchSprite* SubTest::createSpriteWithTag(int tag){ TextureCache *cache = Director::getInstance()->getTextureCache(); Sprite* sprite = NULL; switch (subtestNumber) { /// case 1: case 2: { sprite = Sprite::create("Images/grossinis_sister1.png"); _parentNode->addChild(sprite, 0, tag+100); break; } case 3: case 4: { Texture2D *texture = cache->addImage("Images/grossinis_sister1.png"); sprite = Sprite::createWithTexture(texture, Rect(0, 0, 52, 139)); _parentNode->addChild(sprite, 0, tag+100); break; } /// case 5: { int idx = (CCRANDOM_0_1() * 1400 / 100) + 1; char str[32] = {0}; sprintf(str, "Images/grossini_dance_%02d.png", idx); sprite = Sprite::create(str); _parentNode->addChild(sprite, 0, tag+100); break; } case 6: case 7: case 8: { int y,x; int r = (CCRANDOM_0_1() * 1400 / 100); y = r / 5; x = r % 5; x *= 85; y *= 121; Texture2D *texture = cache->addImage("Images/grossini_dance_atlas.png"); sprite = Sprite::createWithTexture(texture, Rect(x,y,85,121)); _parentNode->addChild(sprite, 0, tag+100); break; } /// case 9: { int y,x; int r = (CCRANDOM_0_1() * 6400 / 100); y = r / 8; x = r % 8; char str[40] = {0}; sprintf(str, "Images/sprites_test/sprite-%d-%d.png", x, y); sprite = Sprite::create(str); _parentNode->addChild(sprite, 0, tag+100); break; } case 10: case 11: case 12: { int y,x; int r = (CCRANDOM_0_1() * 6400 / 100); y = r / 8; x = r % 8; x *= 32; y *= 32; Texture2D *texture = cache->addImage("Images/spritesheet1.png"); sprite = Sprite::createWithTexture(texture, CC_RECT_PIXELS_TO_POINTS(Rect(x,y,32,32))); _parentNode->addChild(sprite, 0, tag+100); break; } /// case 13: { int test = (CCRANDOM_0_1() * 3); if(test==0) { // Switch case 1 sprite = Sprite::create("Images/grossinis_sister1.png"); _parentNode->addChild(sprite, 0, tag+100); } else if(test==1) { // Switch case 6 int y,x; int r = (CCRANDOM_0_1() * 1400 / 100);//.........这里部分代码省略.........
开发者ID:fordream,项目名称:Snake,代码行数:101,
注:本文中的CC_RECT_PIXELS_TO_POINTS函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 C++ CC_RECT_POINTS_TO_PIXELS函数代码示例 C++ CC_RADIANS_TO_DEGREES函数代码示例 |