very idiosyncratic bug in sprite animation

This forum is currently in read-only mode.
  • 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

    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
  • 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?

  • 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

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • 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.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)