suggestion: flipping frames via script

Started by Dave Gilbert, Mon 18/12/2006 18:01:21

Previous topic - Next topic

Dave Gilbert

In my current game, I am using character portraits that have a variety of facial expressions and blinking animations. I had wanted to flip them so they match the direction that the character sprite is facing, but I find myself unable to do that. 

I can create extra views that contain the flipped sprites, but since each character has about 3-6 expressions and 3-6 blinking animations, that would nearly double the number of views in the game.  Is there any way around this?

monkey0506

#1
Well if ViewFrame.Flipped was made writable then you could use that. Until then...DynamicSprite.Flip.

Code: ags
ViewFrame* frame = Game.GetViewFrame(cEgo.View, cEgo.Loop, cEgo.Frame);
DynamicSprite* spr = DynamicSprite.CreateFromExistingSprite(frame.Graphic);
spr.Flip(eFlipLeftToRight);


P.S. The manual entry for ViewFrame functions and properties seems to have gone missing off of adventuregamestudio.co.uk. It's still in the Wiki though.

Dave Gilbert

I was all set to use the "flipped" parameter but then discovered it wasn't writable, yeah. :(  I also thought about the dynamicsprite option, but how can one apply that to talking portraits?


monkey0506

...Huh...it's not possible to set a Character's graphic to a DynamicSprite is it...? I was thinking it was but looking over the manual I don't see an option to do it... :-\

Overlay.CreateGraphical? Yeck this is getting nasty.

SSH

Of course, you can set anything to a Dynamic Sprite: just use the DynamicSprite.Graphic property to get its sprite number...
12

monkey0506

Oooohhhh.....oops. ViewFrame.Graphic is writable...but then you couldn't rely on ViewFrame.Flipped anymore to tell you if the graphic was currently flipped.

SSH

Well, as with anything with Dynamic Sprites, you don't want to keep them around longer that necessary, so I'd just flip them on the fly as required then restore the original sprites afterwards.
12

Dave Gilbert

This is an ancient post.  Sorry!  When I started this thread 4 years ago I didn't realize there was a reply. :)

Anyway, I am working on a project where the ability to flip frames via the script would come in very handy.  If I understand SSH's suggestion correct, the proper way of doing this would be:

1 - create a dynamic sprite, using the frame's graphic and flipping it
2 - set the frame to the dynamic sprite
3 - when you're done with it, reset the sprites afterward.

Is that correct?  I know this question was originally asked during the regime of an older version of AGS. Is there a better way of doing this now?  I looked through the manual but couldn't find anything relevant.

Thanks again!  I promise I won't take another 4 years to respond. :)

-Dave

SMF spam blocked by CleanTalk