Long-term animation

Hi everyone!

I need to realize long-term animation (500 PNG files, size: 800x400). Therefore I cannot use sprite sheet - Spriteloq said that 443 frames left (huge size of sprite sheet). I tried to use movieclip, but I caught memory warning and saw only black display every time I used more then 266 PNG files in movieclip file seqence.

[lua]local movieclip = require(“movieclip”)
local foreground = display.newGroup()

local imageTable = {}
for i = 1, 500 do
table.insert(imageTable, “cat_merry_stop” … i … “.png”)
end

local animation = movieclip.newAnim(imageTable)
foreground:insert(animation)

animation.x = display.contentCenterX
animation.y = display.contentCenterY

animation:play()[/lua]

So, I desided to use programmatic animation.

[lua]local i = 0
local image = nil

local function animate(event)
i = i + 1

display.remove(image)
image = display.newImage(“cat_merry_stop” … i … “.png”)

image.x = display.contentCenterX
image.y = display.contentCenterY

if i >= 500 then
i = 0
end
end

Runtime:addEventListener(“enterFrame”, animate)[/lua]

This code works as expected, but animation is blinking at the end of each iteration (of animation). I don’t know why. What should I do? Perhaps I should use another way of realizing of this task. My aim is long-term (‘rich’) animation.

Please help me! I’m a beginner in Lua and Corona SDK. [import]uid: 154990 topic_id: 27464 reply_id: 327464[/import]

Hey there, I didn’t see any blinking here - are you getting it on device, simulator or both?

One option might be to remove the old image after putting in the new one, have you tried that? [import]uid: 52491 topic_id: 27464 reply_id: 111629[/import]

Thanks for reply, Peach Pellen!

>> Hey there, I didn’t see any blinking here - are you getting it on device, simulator or both?
Both. I was surprised of this fact. Device is iPad 2.

>> have you tried that?
No, because I have lack of knowledge of Lua and Corona SDK. I don’t know how to realize it. Sorry. [import]uid: 154990 topic_id: 27464 reply_id: 111641[/import]

I am also surprised by that; I can’t test this on device right now as I’m in the process of moving interstate and all my testing devices are in boxes about 300 miles away by now :wink:

That said I will be set up again by the end of next week; at that stage if you bump this thread I would be more than happy to test this.

To remove the image immediately after the new one loads you’d want to use a table to put your images in so they could be assigned unique names, then move the code for display.remove() to below where you load the new image. Does that make sense or do you need further explanation? I know when you are quite new you might need some extra help and that’s just fine, just let me know :slight_smile:

Peach [import]uid: 52491 topic_id: 27464 reply_id: 111907[/import]