Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Android / sprite animation from atlas not playing on Android device

Author
Message
mindsclay
11
Years of Service
User Offline
Joined: 1st May 2012
Location: Rocklin, CA, USA
Posted: 7th Nov 2014 08:26


The image "table_halved.jpg" is a texture atlas. This works on my PC.

On my Android device, "table_halved.jpg" is displayed for about a half second then the screen goes blank. The sprite is never displayed, only the atlas.

home.wavecable.com/~mindsclay
mindsclay
11
Years of Service
User Offline
Joined: 1st May 2012
Location: Rocklin, CA, USA
Posted: 7th Nov 2014 08:27 Edited at: 7th Nov 2014 08:32
Here is the entire code:



home.wavecable.com/~mindsclay
Naphier
13
Years of Service
User Offline
Joined: 2nd Oct 2010
Location: St Petersburg, Florida
Posted: 7th Nov 2014 21:07
How big is the sheet?
Android max texture size is 2048x2048
From your code it looks like each frame is 960x540 which is HUGE for a sprite animation.
If you really need that size you will need to create multiple sheets and then you AddSpriteAnimationFrame(spriteID , imageID). This can be a bit slow to load though, but only 4 frames shouldn't be too bad.
Also, you might want to note that iOS has a max texture size with AppGameKit of 1024x1024 so if you ever plan on publishing for Apple you'll also need smaller sheets for that.

Can I ask what you're trying to accomplish? Such a large frame is pretty uncommon.

mindsclay
11
Years of Service
User Offline
Joined: 1st May 2012
Location: Rocklin, CA, USA
Posted: 8th Nov 2014 02:51 Edited at: 8th Nov 2014 03:19
The reason I am using sprite animation is because we are allowed only one video at a time.

Using AddSpriteAnimationFrame was my original approach, but the initialization of the sprites was taking too long and the Android tablet would timeout (the player crashes)

So I thought I would try the atlas method.

All of my animations are small, except for one. I was trying to have all animations initialized in the same way, but it looks like I will need to use a video for the larger animation.

But... MP4 will not allow 960x540, a 16:9 ratio.
Also, when stopping and deleting a video, a purple screen replaces the video and also displays in the upper left corner of the screen for about a second. This has not been remedied in V2.

Thanks for the reply.

home.wavecable.com/~mindsclay
Naphier
13
Years of Service
User Offline
Joined: 2nd Oct 2010
Location: St Petersburg, Florida
Posted: 8th Nov 2014 07:29
Yeah, I tried doing something like this for the loading animation for dFenz since video wasn't working well at the time. I had 14 frames I was trying to load up at launch. It was terribly slow so I dropped it altogether. I've not used video since.

MP4 will allow any size. If you're having issues with sizing it then try Handbrake. It's what I use for our videos and actually just made an ad yesterday for that exact size. I'm not sure what you're using that won't allow that size.

I haven't played with AppGameKit video since 10821. I'm surprised it is still buggy. I guess if no one uses it then Paul never knows about the issues.

You could also try splitting the image up into multiple sheets.

PS - Interesting... I just tried broadcasting video to the AppGameKit player and get a black screen... Fun stuff!

mindsclay
11
Years of Service
User Offline
Joined: 1st May 2012
Location: Rocklin, CA, USA
Posted: 8th Nov 2014 09:31
In order to render the video at my proprtions, I had to render as Quicktime MPEG-4. Trying to use MainConcept MPEG-4 disallowed 960x540 and kept trying to change it to 720x480. The Quicktime trick worked. ( I render animations via After Effects because Vegas won't render MP4 as it will crash each time).

I was getting a black screen as well until I realized that GetImageHeight() and GetImageWidth() were returning a "zero" for the Android tablet I am using. It does not do that in the PC environment. Hardcoding the height and width allowed the video to display on the Android device.

I like to write flexible code that calculates sizes and locations no matter the size of an image or video. But if GetImageHeight() won't work on all platforms I will need to develop a trick for that.

home.wavecable.com/~mindsclay
mindsclay
11
Years of Service
User Offline
Joined: 1st May 2012
Location: Rocklin, CA, USA
Posted: 8th Nov 2014 09:36
Now I am getting a phantom "irregular number of brackets" error. I have isolated the code via remstart and remend, but there is no discernible issue.

But that's for another thread.

home.wavecable.com/~mindsclay
mindsclay
11
Years of Service
User Offline
Joined: 1st May 2012
Location: Rocklin, CA, USA
Posted: 8th Nov 2014 09:50 Edited at: 8th Nov 2014 09:53
Apparently there are some hidden characters that the IDE can see.

But how did they get there? Ugh!

home.wavecable.com/~mindsclay
mindsclay
11
Years of Service
User Offline
Joined: 1st May 2012
Location: Rocklin, CA, USA
Posted: 9th Nov 2014 05:22 Edited at: 9th Nov 2014 05:50
Still, the AddSpriteAnimationFrame method is causing the Android to crash or rather it never comes up.

Any precedence? ny quirks I need to be made aware of? Maybe adding a delay between sprite creation?

home.wavecable.com/~mindsclay
Naphier
13
Years of Service
User Offline
Joined: 2nd Oct 2010
Location: St Petersburg, Florida
Posted: 9th Nov 2014 20:58
Seems to work OK for me using Android 4.4.4 and both AppGameKit 10824 and v2 alpha 7.
What systems are you using?
What's the code?

mindsclay
11
Years of Service
User Offline
Joined: 1st May 2012
Location: Rocklin, CA, USA
Posted: 10th Nov 2014 01:59


I tried using only 2 sprite animations, about 6 frames each, instead of my original 7 sprites. This function is called inside a for/next loop. The "reverse" is for adding frames in reverse order.

I have since went with video clips and that is working.

home.wavecable.com/~mindsclay
Naphier
13
Years of Service
User Offline
Joined: 2nd Oct 2010
Location: St Petersburg, Florida
Posted: 10th Nov 2014 02:33
Glad video clips are working.
If you're getting a crash on Android with the above code, but not Windows you are probably accessing one of the arrays our of bounds.
If you're using v2 then you can check this by doing something like this:
if animSpriteNum < 0 or animSpriteNum > animRev.length
Message("Woops out of bounds animSpriteNum = " + str(animSpriteNum))
//prevent android from closing before we read the message
while GetRawKeyPressed(27) = 0
sync()
endwhile
END
endif
If not v2 you can do something similar by storing the size of the array in a variable.
I don't see where your initiating those arrays so no clue on the sizes. 99% of the time a random crash without message on Android is array OOB.

How'd you get video to work? Mine still just does the sound. Did you have to set the dimensions or something?

mindsclay
11
Years of Service
User Offline
Joined: 1st May 2012
Location: Rocklin, CA, USA
Posted: 13th Nov 2014 04:15
Message is not working for me. It states incompatible types. Yet, everything is a string.

home.wavecable.com/~mindsclay
mindsclay
11
Years of Service
User Offline
Joined: 1st May 2012
Location: Rocklin, CA, USA
Posted: 13th Nov 2014 04:17 Edited at: 13th Nov 2014 04:19
I am using STR to change an interger to a string as you have, but it does not like that.

home.wavecable.com/~mindsclay
mindsclay
11
Years of Service
User Offline
Joined: 1st May 2012
Location: Rocklin, CA, USA
Posted: 14th Nov 2014 11:16
No out-of-bounds issue.

Is there a limit to the number of frames that can be added to a sprite?

home.wavecable.com/~mindsclay
Naphier
13
Years of Service
User Offline
Joined: 2nd Oct 2010
Location: St Petersburg, Florida
Posted: 14th Nov 2014 16:12
Not that I've encounter. How may frames are you adding?

mindsclay
11
Years of Service
User Offline
Joined: 1st May 2012
Location: Rocklin, CA, USA
Posted: 15th Nov 2014 02:45 Edited at: 15th Nov 2014 02:47
The most is 25 frames. I am trying to load 7 sprites (more if I can resolve this issue). I should mention that the image size is 960x540, with an average size of 70kB. I am developing a point-and-click game with realistic 3D images. I wanted to go full HD but I thought memory restrictions might ensue.

I am still in the experimentation stage trying to isolate the issue.

The first two sprites work okay, they have 25 frames each. The later 5 sprites have only 12 frames each. So that sums to about 110 images. I will try additional sprites one at a time after the first two to see when it stops working.

The animations look better if I use the sprite animations as oppossed to video clips due to compression artifacts. There is also some transitional issues switching between images and video, so I would like to have the sprites working as they transition seamlessly.

home.wavecable.com/~mindsclay
Naphier
13
Years of Service
User Offline
Joined: 2nd Oct 2010
Location: St Petersburg, Florida
Posted: 15th Nov 2014 05:04
I've attached an example of my understanding of how it works.
I've got 4 atlases with 64 frames each. A total of 256 frames.
Each atlas is 1024x1024
It's important that your images are maximum of this size if you plan to support iOS. If just Android and Windows you can do 2048x2048.
It's also very helpful to the engine if the atlas textures you use are power of 2 sized at least along one edge. I think it's best along both sides, but that's debatable.

Hope this info helps.
If not feel free to email me your files and I'll take a quick look. You can watermark the images if you're concerned about copyright protection.

Attachments

Login to view attachments
mindsclay
11
Years of Service
User Offline
Joined: 1st May 2012
Location: Rocklin, CA, USA
Posted: 21st Nov 2014 13:49
Atlases won't work for me since my images are 960x540 (maybe later 1280x720).

I wanted to try using Atlases because adding the frames one at a time using AddSpriteAnimationFrame was causing timeout after the player receives the broadcast.
I reduced to the first two animations and it works fine. But I need more than two. Using video causes delays, using sprites does not.

home.wavecable.com/~mindsclay
Naphier
13
Years of Service
User Offline
Joined: 2nd Oct 2010
Location: St Petersburg, Florida
Posted: 22nd Nov 2014 08:17
Works fine for me.
48 frames of individual images, 768x1280 each.
Tested on Windows 7 and Nexus 5. AppGameKit v10824 and AppGameKit v2 alpha 7.

A few things with your code:
Test to make sure the file exists before trying to load the image.
Make sure you call sync() periodically when loading the images. Takes about 4 seconds on my Nexus 5 to load all of those images. If I wasn't calling sync then Android might time out the app. If that doesn't work then the only other reason I've seen Android crash with a t1 program is due to an array out of bounds.

New example is attached.

Attachments

Login to view attachments
mindsclay
11
Years of Service
User Offline
Joined: 1st May 2012
Location: Rocklin, CA, USA
Posted: 22nd Nov 2014 15:11 Edited at: 22nd Nov 2014 15:13
I'll try the "sync()" advice.

Thanks.

I looked into the "out of bounds" concern and I don't see that being the issue as the first two sprite animations work fine. It must be a time-out issue like you mentioned, probably because there are more frames to add.

I'll let you know my findings.

home.wavecable.com/~mindsclay

Login to post a reply

Server time is: 2024-03-03 11:27:01
Your offset time is: 2024-03-03 11:27:01