Cocos studio 2.2.6 very buggy on mac os

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)

  1. 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.
  2. 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.
  3. 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.
  4. 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.

  1. 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)

  1. 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.

PLEASE FIX THIS

3 Likes

To point 5:

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…

This issue have been fixed here:

https://github.com/cocos2d/cocos2d-html5/pull/2906

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?

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.

Looking forward to your reply.
Thanks very much.

Ok, here we go!

I just removed everything. Then I downloaded fresh cocos 2.2.6, installed it, installed cocos2d-x 3.6 framework. I made very simple project.

Here are the results:

Looks like it looks nice. But it’s cocos simulator.

Now running it on iOS simulator:

So going into conclusion:

  1. All sprites are misplaced, because of anchor point bug.
  2. 3rd tile is offsetted by 1 pixel, however they should be perfectly positioned.
  3. 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:

Looking forward to your reply.
Thanks very much.

I can’t believe it, but changing language to English fixed the problem!
I was using polish (polski) language:

I think that can be fixed.

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.

By the way: Label’s shadow doesn’t work on iOS.

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!):

gap 0 pixe - OKl:

gap 1 pixel - OK:

Here are screenshots from DEVICE (you can see 1 pixel lines in few places):

gap 0 pixel - NOT OK:

gap 1 pixel - NOT OK:

You should open images in 100% size in order to clearly see it.

It’s very tiny graphical issue, but still unacceptable for tiles.

The only way now is to remove tiles from sprite sheet and just use them directly.

Finally this is my testing project: I removed as much as I could, you have to only paste cocos2d directory inside (which has a huge size):

And please answer my previous question:

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.

1 Like

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?

Thanks,
Jay

You need to give me more details to help you on the shadow issue.

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.

Great! Let me know when you’ll discover something!

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:

Specifically, I think that the extrude by 1 pixel made it finally work. Give it a try and tell me how it went!

@iPruch @piotrros this extra line pixel from texture packs is a long standing bug. If you want a real working solution refer to my github issue here: https://github.com/cocos2d/cocos2d-x/issues/12847 I spent weeks and weeks trying figure this out.

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.

1 Like