Skip to content

Instantly share code, notes, and snippets.

@sag333ar
Created September 4, 2014 14:17
Show Gist options
  • Save sag333ar/b7d64734610951e08e9a to your computer and use it in GitHub Desktop.
Save sag333ar/b7d64734610951e08e9a to your computer and use it in GitHub Desktop.
Create Sprite in Cocos2d-x
// create the sprite
auto spriteLeft = Sprite::create("FortuneWheel.png");
// get the texture size / image size
auto spriteLeftRect = spriteLeft->getTextureRect();
// set the position of sprite
spriteLeft->setPosition(Vec2(visibleSize.width-spriteLeftRect.size.width/2-20 , spriteLeftRect.size.height/2+40));
// add the sprite to scene-layer
this->addChild(spriteLeft, 4);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment