View offset after a one-off animation

Started by MurrayL, Fri 30/10/2009 00:39:01

Previous topic - Next topic

MurrayL

Hi guys,

I've searched the forums for an answer to this problem, and unfortunately I've only seen answers that don't quite help.

I have a character who has to play a one-off animation of jumping backwards. This is fine in and of itself - the animation plays fine in-game and the start of the animation is nicely lined up with where the character is to begin with.

The problem is that once the animation has finished it unlocks the view and, of course, the player character jumps back to where they started.

I'm currently using LockViewAligned (aligning to the left), but obviously it only aligns the jump animation. Is there some way of aligning the normal view, after you unlock it, to the last frame of the previous animation?

Hope this makes sense - it's driving me crazy.  ???

I realise that I could manually modify the characters X/Y values to move them into the right place, but it feels like there should be an easier method.

Calin Leafshade

The X/Y positions denote the centre bottom of the sprite and thus the location of the character.

If the character has jumped back then he has MOVED position, therefore you need to change the x/y position since he isnt in the same place he was before.

Khris

Yeah, unfortunately, AGS doesn't have an AI that analyzes sprites and determines position changes automatically. ;)

Scarab

Quote from: Khris on Fri 30/10/2009 11:19:19
Yeah, unfortunately, AGS doesn't have an AI that analyzes sprites and determines position changes automatically. ;)

... Yet

CJ, get to work, you lazy slob! :P

Calin Leafshade

I'm still waiting for the 'Make My Game For Me, Its About Zombies' button.

MurrayL

Okay, well I've done it now by changing the x position of the character manually after unlocking the view.

I don't see why there couldn't be an unlockViewAligned method though. If one can lockViewAligned to the left, centre or right of the previous frame, then surely you should be able to do the same thing again afterwards?

Just a suggestion, and of course that's not for this forum  ;)

Shane 'ProgZmax' Stevens

I'm not even sure why you're using Lock and Unlock anyway.  CJ made them almost entirely obsolete when he gave views infinite loops.  You could quite easily make loops down to 14 for the walk view and place your backwards jump animation there and just run it, update player x, then set loop to whatever you want.  No muss, no fuss.

Calin Leafshade

I find lockview to be useful from an organisational standpoint.. they keep the animations seperate and easy to access... Though you are right they are not needed.

monkey0506

There is the benefit that when you call UnlockView it stops any current animation you might be (repeatedly) running on that character. AFAIK there's no other way of stopping that is there? Does changing the Loop/Frame stop animations?

Oh, also as per the manual:

QuoteBefore using this command [(Character.Animate)], you should use LockView in order to select the view you want to animate with and prevent any automatic animations (eg. walking or idle animations) from playing.

So there's also the benefit of preventing automatic animations overriding a custom animation. Not completely deprecated...

Shane 'ProgZmax' Stevens

Idle animations won't interrupt a blocked animation regardless, and if you're triggering a noblock it's trivial to turn idles off and on again.  Heck, you could write a simple wrapper function to do a nonblock animation with disabling the idle anim if you wanted.  I've never run into an issue with it in the many, many, many animations in my games, though.  An easy way to stop a loop is to re-run that same loop (or a walkcycle, or whatever) noblock and no repeat (or play it blocking if interruptions don't matter). 

Pumaman

I see what you mean, there could be an UnlockViewAligned too. But generally, it's assumed that all frames of a particular animation will be the same size which is why this is not currently provided.

SMF spam blocked by CleanTalk