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

@IgnisDesign

Thanks for your time, Brent. You’ve been a great help!

I have also came up with yet another solution in the meantime. Basically, if I “label” each frame in JSON with a number (1,2,3 etc.) then I can use it as a position index when inserting into the LUA array, like this:

[lua]for index,value in pairs(…) do

table.insert(frameOptions.frames, index, newFrame)[/lua]

Again, thank you and I hope that and this will help someone! [import]uid: 133145 topic_id: 23275 reply_id: 98800[/import]

If you have control over the JSON why not add a “name” element to each frame in the JSON, then create a mapping table that maps each name to its index in the table, and use that to look up the index when you want to create the sprite? That way you don’t have to worry about indexes at all. [import]uid: 131129 topic_id: 23275 reply_id: 98802[/import]

@Brent Sorrentino said:
"
One possible issue… And I say “possible” because it might be part of point #3 above (image groups). I tried a basic scenario with image groups and they didn’t clean up properly; as in, they locked the texture memory from the “parent” imageSheet and would not release it, even when the image group children were removed, the group itself removed, and then the group nil’led out. Has anybody else observed or tested this? My testing was fairly basic so I don’t want to claim this is a proven bug at this point… just something to check into.
"

I’m experiencing the same thing. It doesn’t happen if I swap the image group out for a regular display group. Did you ever figure out what’s causing this? [import]uid: 119678 topic_id: 23275 reply_id: 98916[/import]

@IgnisDesign: Have you figured out how to clean the Texture Memory when using an Image Group (your first post)? I’m having the same problem as you.
[import]uid: 135590 topic_id: 23275 reply_id: 98998[/import]

I never found a solution to image groups failing to clean up and release texture memory. I just put it aside and opted to not use image groups at all. Maybe I’ll revisit them later when Ansca fixes this bug (would somebody like to file a bug report for this? It’s clearly a bug if you and others are experiencing the same issue that I did).

I also don’t know (yet) what benefit image groups provide and why I should use them. Image *sheets* I can see a direct benefit from, both in design (graphically) and implementation (in Lua code). Image *groups*, not so much… I guess they’re like sub-classes of display groups, but they can’t be nested in other image groups, and then there are limitations on the capabilities of images contained within them (in regards to masking, tinting, etc.). I’m sure there is a very specific reason Ansca created these, but I’ll need more than a generalized statement like “these provide some nice under-the-hood benefits” to justify implementing them into my game. I’m talking 5+ FPS performance increase across the board by using them; otherwise I probably won’t bother. :slight_smile:

Brent
[import]uid: 9747 topic_id: 23275 reply_id: 99005[/import]

I am attempting to update my tile map code to use the latest image sheets etc for maximum speed increases, and I am getting an interesting crash when using sprites in image groups.

Essentially I create the image sheet, create a single animation that contains all the frames, then create sprites for the entire screen, and use setFrame( index ) to change to the frame.

The fun part is that it works with normal display groups, but if I replace:

tileLayerData.group = display.newGroup() – OLD

with:

tileLayerData.group = display.newImageGroup( self.imageSheet ) – NEW

then the demo starts, displays the first frame, and then the simulator crashes and I get the following output in the message window:

Corona Simulator(1060,0xad1592c0) malloc: *** error for object 0xe46e04: incorrect checksum for freed object - object was probably modified after being freed.
*** set a breakpoint in malloc_error_break to debug
/Applications/CoronaSDK/Corona Terminal: line 9: 1060 Abort trap: 6 “$path/Corona Simulator.app/Contents/MacOS/Corona Simulator” $*

[EDIT]
I should point out that I can get the image groups working if I comment out the setFrame() line in the sprites, which gives me an almost dreamy 100% speed up compared to the equivalent code of ye olde sprites (could be more actually, but I don’t have a test level with more than 6 layers of fullscreen parallax, and it was hitting 60fps consistently!) but isn’t a real-world test case as no swapping of frames = every tile in the world is identical :frowning: [import]uid: 46639 topic_id: 23275 reply_id: 99404[/import]

After more experimenting, I find the bug can be avoided, and the :setFrame() works, but only if I do not make my new image sheet sprites visible and invisible. It is apparently this, in combination with :setFrame() that triggers the memory crashing (and I just tested, it crashes on the device too).

The set up is using Tiled data, where a tile value of 0 represents ‘no tile’ - which translates (in my case) to making the relevant sprite invisible - any other value makes it visible. My inner code loop is this:

if tileIndex == 0 then tileSprite.isVisible = false else tileSprite.isVisible = true tileSprite:setFrame( tileIndex ) endSo the above code will crash. To prevent it crashing I can do one of two things, comment out the :setFrame() line, or comment out the pair of .isVisible lines. Either way the game works fine.

HTH.

[EDIT]My simple tests using normal display groups and image sheet groups is that image sheet groups provide me with a FPS boost of 160% (from 18 to 42). So ummm yeah, they are definitely worth using, even in cases which aren’t so graphically intensive as multiple tilemaps at once) :slight_smile:

[EDIT #2]Entered into the bug database as bug #13479 [import]uid: 46639 topic_id: 23275 reply_id: 99556[/import]

@rakoonic,

Thanks for taking your time to conduct all of these performance tests and bug testing. This is definitely useful to everybody. Your results on actual performance increase of 160% is impressive, so I will definitely implement image groups into my game at some point in the future.

Also thanks for adding the bug to the bug database. That has been holding me up, but once they fix it I’ll have no more excuses to avoid using this API. :stuck_out_tongue:

Brent
[import]uid: 9747 topic_id: 23275 reply_id: 99595[/import]

I should point out I tried to do a simple bit of code to show the bug, and submit that to the bug data base, but I couldn’t replicate it directly, so am now working on stripping out code and what-not from my demo in case they need that.

I did a much longer post covering my findings about performance gains and what-not here:
http://developer.anscamobile.com/forum/2011/07/26/update-performance [import]uid: 46639 topic_id: 23275 reply_id: 99603[/import]

Can anyone confirm or otherwise if all graphics now benefit from culling, or is it just the new imagesheet bits? [import]uid: 46639 topic_id: 23275 reply_id: 99802[/import]

Just to update - Sean 99% confirmed only the new graphics features get the culling code. [import]uid: 46639 topic_id: 23275 reply_id: 99892[/import]

How are sprite bug fixes coming? There are several bugs that need to be fixed before we can release our next game.

  • Setting an animation to loopCount of 1 and the animation gets stuck after playing once. It never plays again no matter how many times you call play

  • Trimming seems to work on 1x sprites, but on everything else there seems to be problems. All our animations jitter and/or some sprites edges are chopped. [import]uid: 9840 topic_id: 23275 reply_id: 100478[/import]

What are the bug numbers for these issues? I did a quick search for the keywords “loopCount” and “trim” and nothing came up.

If you haven’t already, please submit the bug at: (http://developer.anscamobile.com/content/bug-submission)

And attach a simple test case that our support team can use to reproduce/verify the issue. Once they’ve done that, they can send it over to the eng team for prioritization.
[import]uid: 26 topic_id: 23275 reply_id: 100489[/import]

Is dynamic resolution broken on imageSheets at the moment?

I’m experiencing some odd behavior where the “upscaled” version of my graphic is an exploded version of the upper left quadrant of the original image.

The displayed 1 x version is fine. [import]uid: 73951 topic_id: 23275 reply_id: 101442[/import]

is it true that the sprite listener is only triggered for the first and last frame of the animation? [import]uid: 90610 topic_id: 23275 reply_id: 101576[/import]

Anyone experiencing problems with 2x graphics when using imageSheets? [import]uid: 73951 topic_id: 23275 reply_id: 101724[/import]

Is there an API reference for imagesheets? The things I can use etc.
Also I can’t seem to find how to use an external file with imagesheets.
I have my imagesheet/spritesheets in an external file which makes my code less cluttered.

Since the regular spritesheet api will be gone soon it would be nice to be able to switch. [import]uid: 100901 topic_id: 23275 reply_id: 101853[/import]

is it true that the sprite listener is only triggered for the first and last frame of the animation?

and how to dispose?? [import]uid: 90610 topic_id: 23275 reply_id: 102051[/import]

Update:
The problem below had to do with TexturePacker rather than Corona. It seems the last image added to a texturesheet will not behave properly, so I simply added another image at the end and everything works fine.

Like crawlspacegames above, I too have experienced clipped images when making sprites from imagesheets.

Edited to say that the sprite in question will not rotate properly either. I am using this code to make it move towards the player:

local angle = math.atan2(player.y-object.y,player.x-object.x)  
object.x = object.x + math.cos(angle)\*object.speed  
object.y = object.y + math.sin(angle)\*object.speed  

Other sprites from the same spritesheet will rotate and display properly.
The spritesheet is made with the free version of TexturePacker. [import]uid: 99737 topic_id: 23275 reply_id: 102438[/import]

Dunno whether this is a bug or not, but the blog post says “No per-object blend mode”. This sort of implies that there’s a way to, say, set a blend mode for an entire imageGroup. And I have something that would really benefit from imageGroups, except that it really, really, has to be additive to be of any use to me. Quick testing has not produced any way to get imageGroups or their contents to render additively. [import]uid: 143026 topic_id: 23275 reply_id: 104803[/import]