very idiosyncratic bug in sprite animation

Forum for plugin, effect and behavior programmers. Please use the Help & Support forum for help using Construct.

Post » Sat Jun 20, 2009 11:41 pm

I want to submit a bug report, but I'd like some verification as to whether or not I'm missing something:

the following code:
destroys all MySprites,
creates one MySprite,
and sets the frame to MyInteger

//destroy previous instances
[code:bwqd537a]CRunObject** instances;
int count;
pRuntime->GetTypeInstances(MySpriteType, instances, count);

if (instances != NULL)
{
CRunObject** i = instances;
CRunObject** end = instances + count;

for ( ; i != end; ++i)
pRuntime->DestroyObject(*i);
}[/code:bwqd537a]

//Create One New Instance
[code:bwqd537a]MySprite = pRuntime->CreateObject(MySpriteType,0,pLayout); [/code:bwqd537a]

//Set Animation Frame to MyInteger
[code:bwqd537a]pRuntime->SetAnimationFrame(MySprite,MyInteger);[/code:bwqd537a]
//stop animation
[code:bwqd537a]MySprite->info.curAnim->speed=0; [/code:bwqd537a]

If you set MyInteger to anything other than 0 (frame 1 inside construct) it works as expected:
destroys all sprites, creates a new one, sets the frame to MyInteger

if MyInteger is set to frame 0, it works as expected ONLY IF you have a MySprite on the screen area of your layout at startup.
If it is off screen at startup, the sprite will be invisible when you set it to frame 0;
occasionally (rarely) it'll blink on for a split second if you have it set to Always (but it's instantaneously gone, you can barely even see it)

it doesn't make a difference if you destroy on startup or not
and I isolated the code down to this specific combination of commands.
if you don't destroy the other instances first, setting it to the first frame works fine
and if you have the sprite on your startup view, it works fine
and if you set it to any other frame it works fine regardless of where the sprite is or isn't in the layout upon startup

to be clear it doesn't matter whether you place this action in "on start of layout" or later, it just matters whether there is a MySprite on your layout in the visible square inside the layout editor
Spriter Dev
B
87
S
21
G
12
Posts: 3,240
Reputation: 16,461

Post » Sat Jun 20, 2009 11:44 pm

Have you checked the Sprite object source to see how it sets animation frames and speeds? Are you missing a call to update the animations or something similar?
Scirra Founder
B
359
S
214
G
72
Posts: 22,952
Reputation: 178,580

Post » Sun Jun 21, 2009 11:11 am

I'll have to check that later ash
I'm going to be out the most of the day,

also, and perhaps if I am missing a call, it would be the solution to this as well,
but when I ->info.HotSpotX, it returns the hotspot for frame 0, and not the current frame

EDIT: info.HotSpotX returns the current hotspot, there was a simple logic error I had made
Spriter Dev
B
87
S
21
G
12
Posts: 3,240
Reputation: 16,461

Post » Sun Jun 21, 2009 9:56 pm

k
Ash, I tried copying line by line the code from the sprite stop animation, and set animation frame actions, and I can't get the bug to stop happening
there may be a mistake I'm making somewhere
but it would help if I knew what CurAnim->Updated is for
it doesn't seem to make a difference in anything I try
I'm sure it serves a purpose, I'm just not sure what it is.
Spriter Dev
B
87
S
21
G
12
Posts: 3,240
Reputation: 16,461


Return to Construct engineering

Who is online

Users browsing this forum: No registered users and 0 guests