It only appeals to cocos2d-x c++ so binary format (csb). It works well on windows as json version for cocos2d-js. But when publishing csb there are very iritating bugs (some of them I reported before)
Cocos2d-x (csb)
anchor point is not saved. So if you use something other than 0, 0 you have to re-type it in code or your sprite will be moved in another place.
scale is not saved. If you try to use something other than 100% your image will disappear, because scale will be 0. So you have to re-type it in code too.
In the latest version I canât write comma in anchor point input box, I have to copy-paste it. In a version before it worked.
Saved sprites position are misplaced by a tiny amount after publishing to csb. This is extremly bad. I have a âpianoâ as one image and several sprites, which represents active states of keys on the piano. They must be perfectly positioned on the on big image (piano) or youâll see them a bit offsetted. I made a simple test and for example:
one of the keys has a position â198, 81â. But when I run my game (on android in this case, but this happens on ios too) this key is jumping 1 pixel to the left when touched (in my game I just show/hide it when touched) and when I CCLOGâed itâs position I got â197, 81â. Other keys are ok, some are moved in y axis too. So right, I need to re-type positions of all keys in code in order to make sure theyâre on the right place, which kills the sense of using cocos studio.
The same goes for sprite animation. I have several frames, which is a simple animation. And when played in-game frames are jumping by 1 pixel in various directions. When played in cocos studio or in simulator itâs not happening.
So thereâs some serious issue while saving csb file on mac os x. THIS IS NOT HAPPENING ON WINDOWS. I canât look into cocos studio code, because itâs not open source. I also canât save my scene to json file, because itâs only for cocos2d-js.
Saving scene on windows and getting it back to mac os is not a option.
Sprite sheets. Theyâre buggy too. I need to set image gap at least to 1 pixel, disable allow rotation or Iâd experience issues similator to these in point 4.
Cocos2d-js (json)
default blend on cocos2d-js is wrong, I had to change it from GL_ONE to GL_SRC_ALPHA, otherwise spriteâs transparent background was rendering in strange colours, while running on broswer (safari, firefox, chrome). On simulator it looked ok.
I was just making another simple game and I created (in code) grid of tiles. And they were offsetted by 1 pixel from each other. Or to be precise they were on right positions (because I made them from code) but their size was 1px smaller (in both width and height). Tried image gap 0px as well as 1px. So I removed my tile from spritesheet and just used it from seperate file. And the issue was fixedâŚ
I begin to test these bugs on cocos 2.2.6 and cocos2d-x 3.6 on Mac mini(2012) OS X 10.10.3.
To point1:
I change anchor point of x-axis and y-axis to 0.2 and 0.3 in cocos studio and load it in cocos2d-x 3.6, read anchor point source code is in the line 497 of NodeReader.cpp, âanchorxâ and âanchoryâ is 0.2 and 0.3 as same as changed in editor.
To point2:
Like point1, read scale of x-axis and y-axis source code is in the line 487 of NodeReader.cpp, âscalexâ and âscaleyâ is as same as changed in editor.
To point3:
If I understand correctly, you could write comma in anchor point input box on cocos studio 2.2.5, but I test it on cocos studio 2.2.1, 2.2.4, 2.2.5 and it is impossible, anchor point input box only can be inputted number, why you could write comma? Do you download cocos from http://www.cocos2d-x.org/download?
To point4:
Like point1, read position of x-axis and y-axis source code is in the line 486 of NodeReader.cpp, âxâ and âyâ is as same as changed in editor.
My test version is cocos 2.2.6 and cocos2d-x 3.6 from http://www.cocos2d-x.org/download. Please check it again.
Could you give us the project include all error? It is better to give us some operation videos. These would be more helpful for us to fix bug.
All sprites are misplaced, because of anchor point bug.
3rd tile is offsetted by 1 pixel, however they should be perfectly positioned.
Small cocos2d-x logo is invisible, thatâs because of scale bug. Part of this will be visible even with anchor point bug.
As for anchor point: Why I want to write comma? And how I can write â0,5â without comma? Thatâs default value anyway (as you can see on the screenshot). But if I remove it I canât type it anymore. I tried dot too. I can only copy-paste it from other place.
Hereâs that simple project from which I made screenshots:
I think this bug is because cocos wonât support number format in europe, It can not use comma in number input, I had checked your project, use dot in number input and republish resource, it works OK:
Would you please tell us the default language set in your system? Thanks a lot. Hereâs the language setting in my system, and my test screen as following:
As for commas now I can use dot. Previously I couldnât use dot neither comma.
However one bug persisted, it can be spotted on your screenshot too. Which is tiles from sprite sheet. 3rd tile is still offsetted by 1 pixel, however printing in code returns right values.
Remove tile from sprite sheet, publish and poof⌠problem is gone.
By the way why canât you support JSON files in cocos2d-x (js only for now) ?
To this:
However one bug persisted, it can be spotted on your screenshot too. Which is tiles from sprite sheet. 3rd tile is still offsetted by 1 pixel, however printing in code returns right values.
you may change: "#define CC_FIX_ARTIFACTS_BY_STRECHING_TEXEL 0" to "#define CC_FIX_ARTIFACTS_BY_STRECHING_TEXEL 1"
its position at line 90 of ccConfig.h in cocos2d-x 3.6.
To this:
By the way why canât you support JSON files in cocos2d-x (js only for now) ?
Loading json is fast for js, but speed of loading json is much slower than loading csb in C++ and lua, csb is more practical for c++ and lua developer, I think.
If you have any questions or suggestion, please tell us, I look forward to your feedback.
Thanks, that fixed the last problem. If I will find some other bugs I will inform you. Anyway shouldnât it be set to 1 by default?
However I tested it on the other project, because the example project I sent you has precompiled sources so thereâs no way to fix it.
I like the new project template (precompiled sources), because itâs lightweight and compiling extremely fast, but the one reason I canât use it because itâs not generating windows phone project, which I use too, why? Because of that I have huge projects, which I have to clean up time to time in order to save a disk space. So I have to stick with console project generation.
Ok so I thought changing STRETCHING_TEXEL to 1 fixed the problem. But it didnât. I made a bit advanced example (just more tiles; and also images in sprite sheet - otherwise itâs ok!).
Thereâs definitely something wrong with loading a sprite sheet made in cocos studio.
Iâm using sprite sheet without clipping, rotation not allowed, but any size.
I tested image gap 0px and 1px.
And on iPad simulator i cannot see any âholesâ inside tiles, but I can see them on iPad device! iPad mini non-retina (1024x768) to be precise, but tested on others too (including retina) with the same result.
Here are screenshots from SIMULATOR (itâs all right!):
I like the new project template (precompiled sources), because itâs lightweight and compiling extremely fast, but the one reason I canât use it because itâs not generating windows phone project, which I use too, why? Because of that I have huge projects, which I have to clean up time to time in order to save a disk space. So I have to stick with console project generation.
Default Particle and default Bitmap Label do not display when building to iOS. You have to load a custom particle plist and custom fnt file to make these objects actually display on iOS. Is this the way it should be?
I am very interested in this, because I have the same issue with sprite sheets, but I still want to use it because of performance⌠Did you make any progress on this?
Nope I didnât. Just for tiles I excluded them from sprite sheet, because they werenât many. Problem is imo that cocos studio developers are from China I think and are not really reading this or other similar topics. Thereâs a chinese forum for cocos2d-x so maybe someone should be ask there. I once tried to translate it to chinese, but it it looked like google translated it badly and they couldnât understand me.
I went into ccConfig.h file to try setting CC_FIX_ARTIFACTS_BY_STRECHING_TEXEL to 1 and I found an interesting comment:
/** @def CC_FIX_ARTIFACTS_BY_STRECHING_TEXEL
* If enabled, the texture coordinates will be calculated by using this formula:
* - texCoord.left = (rect.origin.x*2+1) / (texture.wide*2);
* - texCoord.right = texCoord.left + (rect.size.width*2-2)/(texture.wide*2);
* The same for bottom and top.
* This formula prevents artifacts by using 99% of the texture.
* The "correct" way to prevent artifacts is by using the spritesheet-artifact-fixer.py or a similar tool.
* Affected nodes:
* - Sprite / SpriteBatchNode and subclasses: LabelBMFont, TMXTiledMap.
* - LabelAtlas.
* - QuadParticleSystem.
* - TileMap.
* To enabled set it to 1. Disabled by default.
* @since v0.99.5
*/
#ifndef CC_FIX_ARTIFACTS_BY_STRECHING_TEXEL
#define CC_FIX_ARTIFACTS_BY_STRECHING_TEXEL 0
#endif
Specifically, this line: * The "correct" way to prevent artifacts is by using the spritesheet-artifact-fixer.py or a similar tool.
Iâll search for this spritesheet-artifact-fixer.py script and give it a try.
Couldnât make it to work. Nevertheless, I donât think this is going to solve anything:
I took a look into the code and all that this script does is to paint a separation line between tiles of the same size, which results in a grid (for example, each 32 px on the X axis and 32 px on the Y axis). That isnât useful for me as my sprite sheet has different sized textures.
In my game I use several textures of different sizes, and some particular textures which are used to build a tower share the same size (256x256 px). These tower tiles present the same artifacts you exposed at the beginning of this thread. Iâve been trying a lot of different combinations (2D projection, disable texture anti aliasing, CC_FIX_ARTIFACTS_BY_STRECHING_TEXEL 1, unchecking âAllow clippingâ and âAllow rotationâ and different values for the âSpacingâ on Cocos Studio⌠Without success. The only method that worked was, as you said, to extract those problematic tiles from the sprite sheet. Then I tried creating a second sprite sheet and gather there only these tiles (without spacing, rotation and clipping), and it worked. After that, I also tried to put another texture which wasnât 256x256 px and then the artifacts appeared again.
In conclusion, if you need to draw sprites which are one next to other and they must perfectly match (this is generally the case of tiles), then donât use sprite sheets for the textures of those sprites, or use a separate sprite sheet which only holds textures of the same size.
Edit: I forgot mentioning that splitting your textures in two sprite sheets that will be used together in the same scene will produce more draw calls. So, if performance is more important to you than preventing the artifacts to show up, stay with only one sprite sheet. If that is not the case (I didnât notice any FPS drop despite the draw calls increase) then use a separate sprite sheet for tiled textures, or even donât drag them into a sprite sheet.
Are you still wondering the solution? I found kind of one! Though it requires Texture Packer, but you can give it a try with the trial period. This program is said to be the best and most complete texture packing software out there, but I tried a lot of configurations and aliasing was still appearing, until I finally managed to find a specific configuration that made aliasing and undesired lines to go away:
I wouldnât use CC_FIX_ARTIFACTS_BY_STRETCHING_TEXEL itâs a hack and doesnât provide a solid solution. Also spritesheet-artifact-fixer.py only adds a padding to the sprites, which is what you can do with texturepacker anyway. And itâs very old, donât bother with that.
One more thing, make sure all your sprites have even dimensions 100x100 for example, not 101x101. This will also help prevent the error from occuring.