Adventure Game Studio

AGS Support => Advanced Technical Forum => Topic started by: Dualnames on Mon 08/03/2010 18:45:57

Title: Character Trail: How? (Solved)
Post by: Dualnames on Mon 08/03/2010 18:45:57
Well, I pride myself in scripting. Mostly because it's written in such a complex way, that even the simplest function appears like something really out of the box. Now, what's today's menu. I want to have a character, that we will name cEgo To have its previous animation leave a trail of a transparent images of himself that will fade away.

It's the exact thing your mouse can do. But i want the mouse trail to fade away, but instead of using a mouse as a template use the current character sprite. I think with my lack of concentration skills it would take me forever.

(http://www.bbc.co.uk/accessibility/win/seeing/pointer/images/pointertrails_98_01.gif)
Title: Re: Character Trail: How?
Post by: Calin Leafshade on Mon 08/03/2010 18:57:29
I did this for a certain unreleased platform game.

Basically each loop I grabbed the sprites from the few preceding frames of the run animation (using viewframe)
and then drew them to the background with progressively more tranparency.

Just make sure you offset each sprite from the main character sprite proportionally to the speed of the character (if your character just has a static speed like the normal AGS walking system then even that shouldnt be a problem)
Title: Re: Character Trail: How?
Post by: Crimson Wizard on Mon 08/03/2010 19:43:06
There's more simple and silly way to do this. NOTE: I never did this, but I guess it must work.
Create dummy characters, amount depends on your wish.
Each character has different transparency.
To achieve effect, position characters in a row and move the to new position each tick after the real character, also changing their View frames accordingly.
Title: Re: Character Trail: How?
Post by: Dualnames on Mon 08/03/2010 19:50:19
Nice code there Calin, only I can't get it to update.

You're having this code run when player is pressing arrow keys. In my way, it's working when I'm placing it on mouse click, though the sprite remains on screen. I'm having 640x400 resolution, with low-resolution coordinates set to true. The room is scrollable and I'm using Ali's Smooth Parallax Module.

I think your platform code, is just based on laws for that certain game, and has no effect on mine, I'm going to do a different approach.
Title: Re: Character Trail: How?
Post by: monkey0506 on Mon 08/03/2010 20:48:54
Regarding the sprite staying on the screen, when you call surface.Release you are overwriting the current background in memory with the DrawingSurface. This is a permanent change. So the next time you grab a DrawingSurface from the room's background, you are grabbing the modified one, not the original. Because of this I would expect the sprite to slowly solidify instead of fading out as expected.

You'll need to use DrawingSurface.Copy to duplicate the original background before you start drawing. The manual has an example on how to do this.