TIP: Trail like Angry Birds
I am currently in production of a Cannon RPG & I explored leaving a trail behind much like that in Angry Birds. After a few minutes of work I discovered this was extremely easy & figured I would leave it as a tip. With this tip you will be able to have the most recent trail shown. I will also show how to make multiple trails stay shown.
I will assume workable knowledge of GS. This is not a beginner tip/tutorial.
Game Attributes needed:
game.Trail #
game.Trails to keep
___________________
ACTOR = Ball
Attributes Needed:
self.trail (integer)
___________________
RULE 1
On release (or whatever 'catapults' your cannonball actor)
Change Attribute self.trail to 1
Change Attribute game.trail # to game.trail # + 1
__________________
RULE 2
If self.trail = 1
Every .1 sec Spawn Actor 'Trail'
(keep relative to actor)
__________________
RULE 3
When Collide w/Blocks or Ground
Change Attribute self.trail = 2
(stops trail)
_________________
ACTOR = Trail
Attributes Needed:
self.trail #
(make sure the actor's moveable attribute is unchecked)
__________________
RULE 1
Change Attribute (not in any rule)
self.trail # to game.trail #
__________________
RULE 2
If game.trail # = self.trail # + game.trails to keep?
Destroy
__________________
You can set game.trails to keep to anything you want. If it is set to 1 it will keep the last trail until your shot is fired. If set to 2 it will keep 2 etc...
__________________
END
So what does this do exactly? This will create a trail behind your actor that shows the player where their last shot went. The reason for the game.trails to keep, is so you can make it an option for the player to be able to keep multiple trails or just the last trail. You could even go one step further & have each trail color coded, but I'll save that for a rainy day
I have tested the performance (on 3G) with spawning that many trail actors every .1 secs & I have not taken any substantial hit with spawning the trail. A cannon game is not exactly the most taxing type of game, so this is a luxury that we can afford.
To see it in action:
http://gamesalad.com/game/play/57549
Enjoy & use however you wish!
As TSB would say:
CHEERS!
I will assume workable knowledge of GS. This is not a beginner tip/tutorial.
Game Attributes needed:
game.Trail #
game.Trails to keep
___________________
ACTOR = Ball
Attributes Needed:
self.trail (integer)
___________________
RULE 1
On release (or whatever 'catapults' your cannonball actor)
Change Attribute self.trail to 1
Change Attribute game.trail # to game.trail # + 1
__________________
RULE 2
If self.trail = 1
Every .1 sec Spawn Actor 'Trail'
(keep relative to actor)
__________________
RULE 3
When Collide w/Blocks or Ground
Change Attribute self.trail = 2
(stops trail)
_________________
ACTOR = Trail
Attributes Needed:
self.trail #
(make sure the actor's moveable attribute is unchecked)
__________________
RULE 1
Change Attribute (not in any rule)
self.trail # to game.trail #
__________________
RULE 2
If game.trail # = self.trail # + game.trails to keep?
Destroy
__________________
You can set game.trails to keep to anything you want. If it is set to 1 it will keep the last trail until your shot is fired. If set to 2 it will keep 2 etc...
__________________
END
So what does this do exactly? This will create a trail behind your actor that shows the player where their last shot went. The reason for the game.trails to keep, is so you can make it an option for the player to be able to keep multiple trails or just the last trail. You could even go one step further & have each trail color coded, but I'll save that for a rainy day

I have tested the performance (on 3G) with spawning that many trail actors every .1 secs & I have not taken any substantial hit with spawning the trail. A cannon game is not exactly the most taxing type of game, so this is a luxury that we can afford.
To see it in action:
http://gamesalad.com/game/play/57549
Enjoy & use however you wish!
As TSB would say:
CHEERS!
Comments
If you want the trail to disappear automatically you could do this..
ACTOR = Trail
(make sure the actor's moveable attribute is unchecked)
__________________
INTERPOLATE alpha to 0
Duration (however long you want each trail actor to last)
__________________
RULE 1
If self.alpha = 0
Destroy
__________________
All my games on Google Play
great tip...
With my method, each new shot causes the previous shots' on-screen marking/markings to fade out. So if they are on say shot 5, shot 4's marking/markings will be slightly faded. Shot 3's marking/markings, slightly more faded. Shot 2's marking/markings even more faded. And, of course, shot 1's marking/markings the most faded.
I keep track of the current shot the player is on and the total number of shots allowed on the current level so that these calculations can occur on the "alpha" color setting. You can basically subtract `"1.0 / ShotCountForCurrentLevel"` off of the marking/markings' alpha with each successive shot. This will evenly fade them out the most you can based on the number of shots for that level while still leaving shot 1 on the screen. When you get up around 7 or more shots per level, it looks pretty neat.
Have to balance all this out in terms of screen clutter and/or performance (if you have a bunch of other stuff going on as well).
If you use Mr. Funkleberry's fade out method with interpolation, I think it would introduce more performance overhead since it would continually be fading out until the end of the interpolate was reached. That is definitely a cool effect. If you implement that and run up against performance issues due to having a bunch of other stuff going on in the scene, then you could fall back to this method since the update is a quick one-time update per marking actor at the start of each new shot.
Hint: You don't necessarily need the whole trail marked either. Depending on how your are implementing it, maybe only a start or end point is needed for aiding the player. Or the draw back point.
http://gamesalad.com/forums/topic.php?id=6537
@ rebump Actually I love the idea of having the trail alpha change based on which shot. This would be pretty easy to accomplish in my game. Don't mind if I 'borrow' the idea do ya? I'll be sure to return it.
The reason I posted this tip is that there was a post a while back about this exact thing & it never got answered. So I wanted to share how to do it.
If you don't like the possible varied appearance per level (due to possible varied shot number allowances for a given level), then you could substitute:
`
Change Attribute -> self.Color.Alpha = self.Color.Alpha - (1.0 / ShotCountForCurrentLevel)
`
to something that consisten for the fading:
`
Change Attribute -> self.Color.Alpha = self.Color.Alpha - (1.0 / MaxShotCountForAnyLevel)
`
or something similar.
Darren.
JamieOneil
Would be great to hear back from anyone here. Or maybe even a simpler way to implement this. I just need a very basic functionality I can grow from...
My 'release' code is also a bit different as I use the BG actor to control this as can be seen here http://gamesalad.com/g/45416
Cheers!
Any help/explanation would be awesome and appreciated.
I'll tinker with some stuff here when I get a chance and let update this thread if I find a simplier means of making it work.
~t
1. I created an integer game attribute called "trailHistory"
2. In my release mechanism, I added a change attribute rule to set game.trailHistory to 2
3. Finally in the trail actor I first added a change attribute and set that to game.trailHistory to 1 when it got spawned
-Then a rule to check to see if the attribute game.trailHistory is equal to 2 then destroy it when it is.
3 steps and it works, so nothing flashy I guess. Basically whenever the release action activates it destroys the previous trail and rinse and repeat.
Just wanted to share this if anyone got confused like myself. Hope it helps
Cheers
~t