Quick Links: Download Gideros Studio | Gideros Documentation | Gideros Development Center | Gideros community chat | DONATE
frame-by-frame animation loading very long on Android. — Gideros Forum

frame-by-frame animation loading very long on Android.

RogerTRogerT Member
edited December 2012 in General questions
Hi guys,
I used the flying bird example to play my own frame by frame animation, with about 40, 480x800 pix, frames.

The FPS rate looks pretty good on the my android device, yet it takes about a minute to load. i.e. Gideros logo flashed on the split screen, then it freezes for about a minute, then starts playing the animation.

Is there any way to speed it up?

Thanks!


main.lua
*****************

local frames1 = {
"10000.jpg",
"10002.jpg",
...
}

local bird1 = MyBird.new(frames1)
stage:addChild(bird1)

*****************


bird.lua
*****************
MyBird = Core.class(Sprite)

function MyBird:init(frameList)

-- create a Bitmap for each frame
self.frames = {}

for i = 1, #frameList do
self.frames[i] = Bitmap.new(Texture.new(frameList[i]))
end

self.nframes = #frameList

-- add first Bitmap as a child
self.frame = 1
self:addChild(self.frames[1])

-- subframe is used to adjust the speed of animation
self.subframe = 0

self:addEventListener(Event.ENTER_FRAME, self.onEnterFrame, self)
end

function MyBird:onEnterFrame()
self.subframe = self.subframe + 1

-- for every 10 frames, we remove the old frame and add the new frame as a child
if self.subframe > 1 then
self:removeChild(self.frames[self.frame])

self.frame = self.frame + 1
if self.frame > self.nframes then
self.frame = 1
end

self:addChild(self.frames[self.frame])

self.subframe = 0
end


-- set the new position
self:setPosition(0, 0)
end

*****************

Comments

Sign In or Register to comment.