2/13/2024 0 Comments Texturepacker polygonThe exporter generates atlas file for Defold and a JSON file for the Spritesheet Split editor script. To ease the generation of such atlases a custom exporter was created for TexturePacker. This new information about the images can be entered by hand or a special user script can be used to prepare such atlases. `Source Width` and `Source Height` indicate the original image size and they are needed to correctly center the trimmed image inside the animation frame. `Source Position X` and `Source Position Y` indicate the position offset of the trimmed image inside the original image from the top left corner. Namely `Source Position X`, `Source Position Y`, `Source Width`, `Source Height`. This feature introduces new fields for images in the atlas outline pane. Therefore only the editor and bob were modified to add the trimmed images support. The engine itself already has support for arbitrary vertex positions for each image which was introduced with the Sprite Trim Mode feature. If you are reading this and you get a different results than mine or find a better way to use the Polygon sprites, please let me know in the comments.Texture sizes can be greatly reduced by trimming transparent pixels around the a … ctual sprite image. Turns out, in my tests, the Polygon sprites are slower than the Quad sprites! Not sure how or why but that is my conclusion! So, I will stick to the original traditional Quad sprites and will not worry about anything. spriteCache->addSpriteFramesWithFile("sprites_ist") Īfter compile and run, 30000 of these sprites are drawn on the screen and the maximum frame rate is…. The only difference in the project is that we add the polygon sprite sheet instead of the quad and change 1 line of code from the previous code to load that sprite sheet. The Polygon Sprites are supposed to be more efficient, so lets repeat the project that we did for the Quad Sprites and see. Sprite3->setPosition(origin.x + visibleSize.width / 2, origin.y + visibleSize.height / 2 - 100) Īfter compile and run, 30000 of these sprites are drawn on the screen and we get the maximum frame rate of 32. Sprite2->setPosition(origin.x + visibleSize.width / 2, origin.y + visibleSize.height / 2 - 100) Īuto sprite3 = Sprite::createWithSpriteFrameName("PolySprite3.png") SpriteCache->addSpriteFramesWithFile("sprites_ist") įor (int i = 0 i setPosition(origin.x + visibleSize.width / 2, origin.y + visibleSize.height / 2 - 100) Īuto sprite2 = Sprite::createWithSpriteFrameName("PolySprite2.png") Vec2 origin = Director::getInstance()->getVisibleOrigin() Īuto spriteCache = SpriteFrameCache::getInstance() Lets see how they perform in a large numbers and then we compare them to the Polygon Sprites to get a better idea of the speed gain.Īfter adding the resource files to the project, the init() method is as below: bool HelloWorld::init()Īuto visibleSize = Director::getInstance()->getVisibleSize() Quad Sprites are the normal rectangular sprites that are created by default when we create a sprite. Texture Packer settings are as shown here:Īs you can see below, the first one is quad and the second one is polygon that has more vertices.ĭownload TexturePacker Projects QUAD Sprite The 3 images are intentionally in a way that they have a lot of empty space. So, I will leave that to you to have a look at, if you really have to!įor this particular test, I have 3 images that were exported as PNG8 from photoshop and I will pack into two sprite sheets, once with QUAD settings and once with POLYGON settings in TexturePacker and run the same code to see which has a better performance. QUAD_BATCHNODE is deprecated and I am not interested in SLICE9 type either. Drawing pixels is more expensive than calculating triangles in a GPU they say! The reason that POLYGON sprites might be faster than QUADs is that even though they might have multiple triangles, they draw less pixels on the screen. I am interested to see how the POLYGON type can improve speed when the sprite shapes are not exactly rectangular. It is basically just a rectangle, made of two triangles. The sprite type! Sprite TypesĪccording to Cocos2d-x documents, there are four different type of sprites:Įverything we did so far was of type QUAD which is the default type. We have made a few sprites by now and we know how to make them fast by packing images into a Sprite Sheet, but there is another factor to consider.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |