Time for action – creating placeholder sprites
So let me show you how to do that:
Go ahead and download the
4198_06_START_PROJECT.zip
file if you haven't done so already.When you open the project in Xcode, you will see all the classes we'll need for the game, and we'll go over them in a second. But for now, just go to
GameLayer.cpp
.Scroll down to the last
createGameScreen
method and add the following lines:auto quickSprite = Sprite::create("blank.png"); quickSprite->setTextureRect(Rect(0, 0, 100, 100)); quickSprite->setColor(Color3B(255,255,255)); quickSprite->setPosition(Vec2(_screenSize.width * 0.5, _screenSize.height * 0.5)); this->addChild(quickSprite);
And that's it. The sprite is created with a texture called
blank.png
. This is a 1 x 1 pixel white square you will find in theResources
folder. Then we set the size of the sprite's texture rectangle to 100 x 100 pixels (setTextureRect
), and fill it with a white color (setColor
). By resizing the texture rectangle, we in effect...