Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: TheManInBoots on Fri 13/09/2019 17:32:44

Title: Can you create a DynamicSprite from the current frame of a Character?
Post by: TheManInBoots on Fri 13/09/2019 17:32:44
Hi!

I just wondered if it's possible to use the current random frame that a Character is in as a Dynamic Sprite, even if the character is in the middle of an animation.

I know that you can extract the sprite of an object for a Dynamic Sprite, which would look as follows:

DynamicSprite* sprite = DynamicSprite.CreateFromExistingSprite(object[0].Graphic);

But can you do the same thing for a character?

I tried replacing (object[0].Graphic) with (character[0].Frame) or (cEgo.Frame) but that does not work, it just shows the blue cup dummy frame.
Title: Re: Can you create a DynamicSprite from the current frame of a Character?
Post by: Snarky on Fri 13/09/2019 18:00:58
Character.Frame tells you the animation frame number within the current character View and Loop. To find the actual Sprite ID you then have to look that up from the corresponding ViewFrame:

Code (ags) Select
ViewFrame* currentFrame = Game.GetViewFrame(cEgo.View, cEgo.Loop, cEgo.Frame);
DynamicSprite* sprite = DynamicSprite.CreateFromExistingSprite(currentFrame.Graphic);
Title: Re: Can you create a DynamicSprite from the current frame of a Character?
Post by: TheManInBoots on Fri 13/09/2019 19:29:13
Cheers! Thanks! :)