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.

AppGameKit Classic Chat / SetSpriteAnimation limited size?

Author
Message
DanW
21
Years of Service
User Offline
Joined: 6th Jul 2003
Location: Boston, MA
Posted: 12th Feb 2017 17:48 Edited at: 12th Feb 2017 18:09
I am trying to use SetSpriteAnimation on a very large tiled image
Water.png is 3416x3360
It contains 28 images. tiled 4x7

AddSpriteAnimationFrame(WaterSprite,LoadImage("Water.png"))
SetSpriteAnimation(WaterSprite, 854 , 480, 28)

When it hits the SetSpriteAnimation line, the program just exits. No error.

If I set the frame number to 1 it correctly displays one frame.
SetSpriteAnimation(WaterSprite, 854 , 480, 1)

Any ideas?
damothegreat
User Banned
Posted: 12th Feb 2017 18:03 Edited at: 12th Feb 2017 18:04
Whats the width and height of each tile? presume 854 x 480? so that will be 4 across and 7.208333333 down - 4 (exactly) * 7.2083333333 = 28.83333333? cool?

I think SetSpriteAnimation needs to be exact and use integrals not floats.

Try and make your picture round to the nearest integral

So lets do 4 across = 3416 / 4 = 854 (ok cool)

Do 7 tiles down = 3360 / 7 = 480 (ok cool)

Maybe change the resolution of your image to 3416 x 3360 and try again?

Make a backup of your original png
Maybe...

Damo
DanW
21
Years of Service
User Offline
Joined: 6th Jul 2003
Location: Boston, MA
Posted: 12th Feb 2017 18:08
whoops. typo...
My image IS 3416x3360



So my question still stands....

damothegreat
User Banned
Posted: 12th Feb 2017 18:19
ok - let us try to replicate and get back to you

damothegreat
User Banned
Posted: 12th Feb 2017 18:27 Edited at: 12th Feb 2017 18:30
Try my code and extract function


Press "Space" to increase frame of the sprite in the animation sequence



Seem to work for me

Damian
DanW
21
Years of Service
User Offline
Joined: 6th Jul 2003
Location: Boston, MA
Posted: 12th Feb 2017 18:54
Yes, that works....

Why?
damothegreat
User Banned
Posted: 12th Feb 2017 18:55
Show me your code?
DanW
21
Years of Service
User Offline
Joined: 6th Jul 2003
Location: Boston, MA
Posted: 12th Feb 2017 18:59
and debugging the function shows that it also calculates 3416x3360 with frame sizes of 854x480
damothegreat
User Banned
Posted: 12th Feb 2017 19:02 Edited at: 12th Feb 2017 19:06
I cannot explain why yours don't work and mine does - without your version of the code that you wrote , so I cannot conclude.

I'm glad your up and running now anyway with my code which you can by all means use in your projects

PS. I found it a challenge with the Animation coding when I first got into AGK. and then I made a rock solid function which should work every time cause it works out the true
width/height without messing about trying to work it out ourselves

More than likely got the height and width wrong and just ever so slightly gone too far in the dimensions at a guess.



Damo
DanW
21
Years of Service
User Offline
Joined: 6th Jul 2003
Location: Boston, MA
Posted: 12th Feb 2017 19:21
could it be that it creates a memblock from the original image?
damothegreat
User Banned
Posted: 12th Feb 2017 19:28
Doubt it - cause I am deleting the memblock from memory straight away cause it has no further use - I just use memblocks to get the true width and height and then divide for how many across and down.

Its a lot easier to count tiles across and down in larger sprite sheets.

I was forever trying to work out the individual tiles when I first doing spritesheets. Which became an arse to work out in an image application - cause it needed to be exact!!!

So memblock gets the exact width and height... then divide by how many across and horizontal and the result can be used in the setspriteanimation function






Mobiius
Valued Member
21
Years of Service
User Offline
Joined: 27th Feb 2003
Location: The Cold North
Posted: 13th Feb 2017 10:14
With an image size of 3416x3360 , you're probably running out of video ram. The png gets converted to uncompressed format internally and that will use a lot of VRAM.
Use a smaller image, try halfing the scale? If you really need images of that size, (And i wholeheartedly would advise against it) try using a video, and not an animated sprite.

Login to post a reply

Server time is: 2024-09-29 23:26:38
Your offset time is: 2024-09-29 23:26:38