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
http://www.giderosmobile.com/forum/discussion/2249/splash-screen-in-android#Item_1
Likes: RogerT
For example, in Java I tried solving it first loading all the frames into a byte[] ArrayList , which takes less then 5 seconds for over 300 frames, and then decode them into a bitmap on the fly. The problem was I couldn't get a steady framerate, it was always jumping from about 10 to over 30. That's why I'm trying Gideros. )
Likes: RogerT
If anybody has any interesting ideas, feel free to share
Likes: RogerT
Likes: RogerT