Created
January 22, 2014 07:39
-
-
Save SONIC3D/8554863 to your computer and use it in GitHub Desktop.
SpriteSheet和SpriteBatchNode
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void GameLayer::useSpriteSheet() | |
{ | |
// 建立SpriteBatchNode | |
// 方法1: | |
CCSpriteFrameCache::sharedSpriteFrameCache()-> | |
addSpriteFramesWithFile("sprite_sheet.plist"); | |
_gameBatchNode = CCSpriteBatchNode::create("sprite_sheet.png"); | |
this->addChild(_gameBatchNode); | |
// 方法2: | |
CCSpriteFrameCache::sharedSpriteFrameCache()-> | |
addSpriteFramesWithFile("sprite_sheet.plist","sprite_sheet.png"); | |
CCTexture2D *fullTexture=CCTextureCache::sharedTextureCache()-> | |
textureForKey("sprite_sheet.png"); | |
_gameBatchNode = CCSpriteBatchNode::createWithTexture(fullTexture); | |
this->addChild(_gameBatchNode); | |
// ----------------------------------------------------------------------------- | |
// 加载在sprite_sheet.plist中描述的sprite | |
CCSprite * sprite; | |
sprite = CCSprite::createWithSpriteFrameName("city_dark.png"); | |
sprite->setPosition(ccp(0, 0)); | |
_gameBatchNode->addChild(sprite); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment