Issues with Imagesheets/Image Groups/Sprites from build 759+

@Brent,
Thanks for the suggestion! That’s kind of what i was trying to do right now, because i really need that part of the game to be functional. As you say, it is not the ideal thing to do, but at least it gets the job done for now.

@rakoonic,
I understand what you say, but i really need the improved performance (and wow it has improved a lot) for this game. For now i haven’t ran across any bug and was hoping ansca gets their hands on this API soon!
[import]uid: 105206 topic_id: 23275 reply_id: 111244[/import]

Brent: this is not enough. We [I] also need the “loop” event.
Sample scenario: Every 4 loops of walk animation I want to change sequence to “hop” animation, play it once and go back to playing walk animation for another 4 loops.

This kind of is crazy. It seems to me, it’s much easier for Ansca coders to implement firing events for frame and for loop then it is to us to work around this limitation and implement it on our own.

I was using enterFrame to trigger “next” events, something like you’ve described, but now when I also need “loop” it gets even more difficult. [Also, not forgetting to stop them when pausing game, start them again when un-pausing… a lot of code].

[import]uid: 109453 topic_id: 23275 reply_id: 111328[/import]

I am also having the “bouncy” issues with x2 and x4 spritesheets…

I made a post in feature request about it:

http://developer.anscamobile.com/forum/2012/06/12/jittery-sprites-fix-or-documentation

and several others with this account and another account of mine in other forums… (they are spread in developers section, texture packer section…)

And I am already nagging people on IRC for 3 weeks.
Seriously, my boss want me to just dump corona and use moai because of this issue, I did not even tested moai, but this is bothering him so much that he is being very serious in dumping corona and warning the investors about it (this mean that all studios with the same investors would probably dump corona too). [import]uid: 142895 topic_id: 23275 reply_id: 111336[/import]

stan8, see my workaround in http://developer.anscamobile.com/forum/2012/06/12/jittery-sprites-fix-or-documentation

you don’t need to switch to moai for this…just load your own sprite sheet by detecting if you are 2x or 4x [import]uid: 122310 topic_id: 23275 reply_id: 111342[/import]

stan8: I had the jittering issue as well, but using --shape-padding 4 --border-padding 4 for HD and --shape-padding 2 --border-padding 2 for SD solved this issue.
You don’t even need to load your own sprite, corona loads my sd/hd images. [import]uid: 109453 topic_id: 23275 reply_id: 111346[/import]

kyrstian6 I tried that, it did not worked. [import]uid: 142895 topic_id: 23275 reply_id: 111356[/import]

stan8 - are you using latest texture packer? Are your sprites evenly sized? Maybe you didn’t notice and one of them is 155 instead of 156?
I have so many sprites, that I wrote a gimp plugin to detect which of them are oddly spaced.

I had the exact problem you have, and fixed it this way. [import]uid: 109453 topic_id: 23275 reply_id: 111370[/import]

The point of texturepacker is let it trim the sprites… How I am supposed to know if it will trim with odd or not spaces? (and also you are the first person to mention that) [import]uid: 142895 topic_id: 23275 reply_id: 111373[/import]

Texturepacker does not support sprite trimming and dynamic scaling yet.
The maker is working on an update to fix it. He explains it somewhere on the forum, why and how etc.
Solutions are also provided. You get two lua files and have each lua file loaded when needed. [import]uid: 100901 topic_id: 23275 reply_id: 111376[/import]

Reposting my reply to @stan8 on the other thread:

Corona loads images (whether they are sprite sheets or normal images) using the suffixes, but only pays attention to the 1x frame data.

This is because when the “require” method only loads the Lua file you specify (no suffixes are added).

The problem is that TexturePacker may not be precisely scaling the images. Corona expects the 2x and 4x images to be precise scales of the 1x image.

A partial solution is similar to what @aisaksen proposes. It’s a hybrid of manual and automatic.

You manually figure out which frame data to ‘require’ (i.e. you specify “data”, “data2x”, etc). And then let Corona automatically load the correct image, based on the content scaling suffixes (i.e. you just pass in ‘sheet.png’ and Corona will load using the suffixes you specify in config.lua).

I’ve contacted Andreas (author of TexturePacker) to see what can be done to improve this. [import]uid: 26 topic_id: 23275 reply_id: 111414[/import]

BTW, since most frame data is in a Lua file, one thing we can do to ameliorate this is offer a new API that tells you the suffix that’s currently being used by Corona to load images:

display.imageSuffix  

So if you are in a situation where you cannot avoid multiple frame data files, you can more easily specify the precise Lua file you want to ‘require’.

local name = "framedata"  
local suffix = display.imageSuffix  
if ( suffix ) then  
 name = name .. suffix  
end  
local frameData = require "name"  
...  

Any thoughts? [import]uid: 26 topic_id: 23275 reply_id: 111415[/import]

@krystian6, dingo, nml, we plan on adding the missing phases. It was an oversight. Will try to get this into a daily build soon after the next public release (we’re days away, so we’ve locked down the code base)
[import]uid: 26 topic_id: 23275 reply_id: 111418[/import]

@Walter: thanks, appreciated! [import]uid: 90610 topic_id: 23275 reply_id: 111464[/import]

Okay, so here’s what the phases will look like, paired against the frame number of the sprite. In the following example, the sprite has 4 frames and loopDirection is set to “bounce”:

1 began
2 next
3 next
4 bounce
3 next
2 next
1 loop
2 next
3 next
4 bounce
3 next

If it’s normal looping (no bounce), then it will look like:

1 began
2 next
3 next
4 next
1 loop
2 next
3 next
4 next

I’ve got this working locally, but it won’t make it to the next public release (as we’ve locked it down except for showstopper bugs). It should be available in one of the first daily builds post-public release.

[import]uid: 26 topic_id: 23275 reply_id: 111471[/import]

Walter: looking forward to it.

I have found another issue though.
I’ve got a “monster” which has an attack animation.
It has 7 frames, and it looks just fine:

[text]

Wed Jun 13 09:42:37 2012 DEBUG Sequence: attack, frame: 1, phase: next, hitFrame: 7
Wed Jun 13 09:42:39 2012 DEBUG Sequence: attack, frame: 1, phase: began, hitFrame: 7
Wed Jun 13 09:42:39 2012 DEBUG Sequence: attack, frame: 2, phase: next, hitFrame: 7
Wed Jun 13 09:42:39 2012 DEBUG Sequence: attack, frame: 3, phase: next, hitFrame: 7
Wed Jun 13 09:42:40 2012 DEBUG Sequence: attack, frame: 4, phase: next, hitFrame: 7
Wed Jun 13 09:42:40 2012 DEBUG Sequence: attack, frame: 5, phase: next, hitFrame: 7
Wed Jun 13 09:42:40 2012 DEBUG Sequence: attack, frame: 6, phase: next, hitFrame: 7
Wed Jun 13 09:42:40 2012 DEBUG Sequence: attack, frame: 7, phase: next, hitFrame: 7
Wed Jun 13 09:42:40 2012 DEBUG Sequence: attack, frame: 7, phase: ended, hitFrame: 7

[/text]

However, when I change the sequence to another one [like when he got “chilled” by some ice magic], something weird is happening. The ice animation also has 7 frames, but now I see:

[text]

Wed Jun 13 09:42:43 2012 DEBUG Sequence: attack_ice, frame: 1, phase: next, hitFrame: 7
Wed Jun 13 09:42:46 2012 DEBUG Sequence: attack_ice, frame: 1, phase: began, hitFrame: 7
Wed Jun 13 09:42:46 2012 DEBUG Sequence: attack_ice, frame: 2, phase: next, hitFrame: 7
Wed Jun 13 09:42:46 2012 DEBUG Sequence: attack_ice, frame: 3, phase: next, hitFrame: 7
Wed Jun 13 09:42:46 2012 DEBUG Sequence: attack_ice, frame: 4, phase: next, hitFrame: 7
Wed Jun 13 09:42:46 2012 DEBUG Sequence: attack_ice, frame: 5, phase: next, hitFrame: 7
Wed Jun 13 09:42:47 2012 DEBUG Sequence: attack_ice, frame: 6, phase: next, hitFrame: 7
Wed Jun 13 09:42:47 2012 DEBUG Sequence: attack_ice, frame: 7, phase: next, hitFrame: 7
Wed Jun 13 09:42:47 2012 DEBUG Sequence: attack_ice, frame: 21, phase: ended, hitFrame: 7

[/text]

Notice the ended phase. In my sprite listener, I can see that animation.frame is set to 21!

I have tried another animation, and instead of 7 I got 28.
It seems, that during ended phase I always get frame number of the imagesheet and not of the sequence! Which is weird, because during the rest of the animation, frame is set to the number from sequence. [import]uid: 109453 topic_id: 23275 reply_id: 111476[/import]

@walter,

Awesome Walter! I’ll look forward to it. [import]uid: 105206 topic_id: 23275 reply_id: 111506[/import]

+1 on image suffix addon, would make it a lot easier for a lot of things not just these trimmed spritesheets. [import]uid: 100901 topic_id: 23275 reply_id: 111533[/import]

@krystian6, yes that’s a bug. We’re working on a fix. [import]uid: 26 topic_id: 23275 reply_id: 112123[/import]

Hi again,

I was testing the new build and noticed something.
Previously [pre build 841] ended phase was sent to the listener AFTER the frame was displayed on screen. Then, when I got the ended phase for that frame I was reseting sequence back.
Now when I want to do that I can’t see the last frame being displayed on screen.

Is this something you are going to change, or is it going to be left as it is right now?
[import]uid: 109453 topic_id: 23275 reply_id: 113162[/import]