Posted: 13th Nov 2011 20:06
I have a big sprite 370 by 450, animated with 37 frames.

When I play more than 15 frames non-looping, the sprite does not play and stop, but loops with no apparent sense. When I play less than 15 frames all works fine, it plays once and stops.
Posted: 13th Nov 2011 21:13
You need to post an example to back this up. Also bear in mind, your sprite is 9.6MB with all animation frames (512x512x37). You also haven't said what the source of the animation is - multiple images or an image atlas.
Posted: 13th Nov 2011 22:10
its a sprite sheet, image atlas.

the filesize is a 1mb 2604 by 2580 image.

i will try to make an example.

its definitely a bug. for the moment i found a solution by putting a StopSprite command at the end when the animation plays.
Posted: 13th Nov 2011 22:40
the filesize is a 1mb 2604 by 2580 image.

But doesn't AppGameKit 'pad' both width and height to the next power of 2? So it would then become a 4096 by 4096 image in memory.
Posted: 13th Nov 2011 23:07
Don't know how AppGameKit works internally.

The game is for the ipad. I am testing on Windows for now.
Posted: 13th Nov 2011 23:44
I'm not sure if it's done on windows but it might be done for ipads. Here's the padding info.
Posted: 14th Nov 2011 9:03
I am enclosing a code sample that demonstrates the bug.

Apparently the culprit is the SetSpriteFrame line.


+ Code Snippet
#include "template.h"
using namespace AGK;
app App;

int testsprite;

void app::Begin(void)
{
	agk::SetVirtualResolution (1024, 768);
	agk::SetResolutionMode (1);
	agk::SetOrientationAllowed (0, 0, 1, 1);

	agk::SetSyncRate(60,0);

	agk::Print("Loading.....");
	agk::Sync();

	testsprite = agk::CreateSprite (agk::LoadImage ("spritesheet.png"));
	agk::SetSpriteAnimation(testsprite, 372, 430, 37);
	agk::SetSpriteOffset (testsprite, 215, 235);
	agk::SetSpriteFrame(testsprite, 1);
	agk::SetSpriteShape (testsprite, 3);
	agk::SetSpritePositionByOffset (testsprite, 500, 570);

	agk::PlaySprite (testsprite, 2, 0, 27, 37);  // play from frames 27 to 37
}


void app::Loop (void)
{
	
	if (agk::GetSpriteCurrentFrame(testsprite) == 37)
	{
		//agk::StopSprite (testsprite);
		agk::SetSpriteFrame(testsprite, 1);
	}

	agk::Print(agk::ScreenFPS());
	agk::Sync();
}


void app::End (void)
{
}
Posted: 14th Nov 2011 23:20
I see what you're saying. It's looping but shouldn't, atleast according to how you set the parameters for agk::playsprite(). Well, atleast you have a solution.
Posted: 14th Nov 2011 23:34
Yes it shouldn't loop, but after it plays, it ERRATICALLY starts playing back other frames from the very start (frames 1, 2, 3 etc). The problem happens on this command: agk::SetSpriteFrame(testsprite, 1);
Posted: 15th Nov 2011 1:48
The use of agk::SetSpriteFrame(testsprite, 1) is throwing off the animation routine since it thinks it hasn't reached 37 yet (it checks just before displaying frame 38 if it should stop, so changing it on 37 deprives it of this check).
Posted: 15th Nov 2011 11:20
frame 38 does not exist since the spritesheet is 37 frames long.

I want to display frame 1 after frame37 (last frame) has finished.
so what do you suggest?
Posted: 15th Nov 2011 12:49
bjadams... Not sure if this helps, but what I tend to do is just let it loop... And then just stop it yourself when it reaches the last frame... For example:

+ Code Snippet
#include "template.h"
using namespace AGK;
app App;

int testsprite;

void app::Begin(void)
{
	agk::SetVirtualResolution (1024, 768);
	agk::SetResolutionMode (1);
	agk::SetOrientationAllowed (0, 0, 1, 1);

	agk::SetSyncRate(60,0);

	agk::Print("Loading.....");
	agk::Sync();

	testsprite = agk::CreateSprite (agk::LoadImage ("spritesheet.png"));
	agk::SetSpriteAnimation(testsprite, 372, 430, 37);
	agk::SetSpriteOffset (testsprite, 215, 235);
	agk::SetSpriteFrame(testsprite, 1);
	agk::SetSpriteShape (testsprite, 3);
	agk::SetSpritePositionByOffset (testsprite, 500, 570);

	agk::PlaySprite (testsprite, 2, 1, 27, 37);  // play from frames 27 to 37 **CHANGE THIS TO LOOP**
}


void app::Loop (void)
{
	
	if (agk::GetSpriteCurrentFrame(testsprite) == 37)
	{
		agk::StopSprite (testsprite); // **STOP PLAYING AT FRAME 37**
		agk::SetSpriteFrame(testsprite, 1); // **SET FRAME TO 1**
	}

	agk::Print(agk::ScreenFPS());
	agk::Sync();
}


void app::End (void)
{
}


Thats always worked for me anyway...
Posted: 15th Nov 2011 14:32
I am using STOPFRAME to get around the problem for how.
Posted: 15th Nov 2011 14:50
Yeah, I thought that was what you were doing... I think what Paul is saying is that the loop hasn't actually finished when you are chainging it to frame 1, thus the loop never had the chance to stop.

What happens if you change this:

+ Code Snippet
	if (agk::GetSpriteCurrentFrame(testsprite) == 37)
	{
		//agk::StopSprite (testsprite);
		agk::SetSpriteFrame(testsprite, 1);
	}


To this:

+ Code Snippet
	if (agk::GetSpritePlaying(testsprite) == 0)
	{
		agk::SetSpriteFrame(testsprite, 1);
	}


Would that work?
Posted: 15th Nov 2011 21:13
I missed the GetSpritePlaying command because its not listed under Sprite animation in the docs.

I think this a a more elegant solution.

However I think there's still a but there, which should be taken care of.