A texture atlas is a large image containing a collection of each sprite. We often use a texture atlas rather than individual images. In this recipe, you will learn how to use a texture atlas.
You have to add the texture atlas files into your project and clean your project.
Let's try to read the texture altas file and make a sprite from it.
auto cache = SpriteFrameCache::getInstance(); cache->addSpriteFramesWithFile("res/running.plist"); auto sprite = Sprite::createWithSpriteFrameName("run_01.png"); sprite->setPosition(size/2); this->addChild(sprite);
Firstly, we loaded the texture atlas file, when the
SpritFrameCache class cached all the images that are included ...