Skip to content

Instantly share code, notes, and snippets.

@kw0006667
Created October 11, 2012 12:50
Show Gist options
  • Save kw0006667/3872076 to your computer and use it in GitHub Desktop.
Save kw0006667/3872076 to your computer and use it in GitHub Desktop.
Add sprite to your scene(.cpp)
// on "init" you need to initialize your instance
bool HelloWorld::init()
{
//////////////////////////////
// 1. super init first
if ( !CCLayer::init() )
{
return false;
}
CCSize size = CCDirector::sharedDirector()->getWinSize();
this->charlie = CCSprite::create("Charlie.png");
// position the sprite on the center of the screen
this->charlie->setPosition( ccp(size.width/2, size.height/2) );
// add the sprite as a child to this layer
this->addChild(pSprite, 0);
return true;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment