Can you create a DynamicSprite from the current frame of a Character?

Started by TheManInBoots, Fri 13/09/2019 17:32:44

Previous topic - Next topic

TheManInBoots

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.

Snarky

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
ViewFrame* currentFrame = Game.GetViewFrame(cEgo.View, cEgo.Loop, cEgo.Frame);
DynamicSprite* sprite = DynamicSprite.CreateFromExistingSprite(currentFrame.Graphic);

TheManInBoots


SMF spam blocked by CleanTalk