TIP: Trail like Angry Birds

JGary321JGary321 Member Posts: 1,246
edited November -1 in Working with GS (Mac)
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!

Comments

  • mrfunkleberrymrfunkleberry Member Posts: 424
    Nice one JGary321.

    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
    __________________
  • izamizam Member, PRO Posts: 503
    Great tip! Thank you very much!
  • StormyStudioStormyStudio United KingdomMember Posts: 3,989
    cool, how well does it run, does spawning not slow down the CPU/Device too much?

    great tip...
  • TouchTiltGamesTouchTiltGames Member Posts: 1,162
    This is awesome. It doesn't look like we can download it though in that link.
  • rebumprebump Member Posts: 1,058
    I'm doing something similar in my current project only from a bit different of an angle. Nice aid for player's having issues with hardness.

    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.
  • rebumprebump Member Posts: 1,058
  • JGary321JGary321 Member Posts: 1,246
    stormystudio said:
    cool, how well does it run, does spawning not slow down the CPU/Device too much?

    great tip...

    Well since there is not a lot going on in a game like this, there is 0 noticeable performance hit. Spawning an actor that has 2 rules is not intensive at all.
    Shizane said:
    This is awesome. It doesn't look like we can download it though in that link.

    Yea sorry, I can't share it, just b/c I have other stuff from my game in it & didn't feel like making just a Demo of it. But it's pretty easy, so I just put the instructions up.

    @ 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.
  • rebumprebump Member Posts: 1,058
    @JGary: "Borrow" away!

    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.
  • dre38wdre38w Member Posts: 79
    Awesome! Thank you so much for this!
  • UtopianGamesUtopianGames Member Posts: 5,692
    Nice tutorial, you could also recycle the trial like we did in our angry birds template (no spawning).



    Darren.

    image
  • JamieOneilJamieOneil Member Posts: 877
    Couldn't you use particles for this ?

    JamieOneil
  • lildragnlildragn Member Posts: 105
    Sorry for bringing this old thread up, but I'm having a bit of trouble implementing JGary321 rules. Even after downloading the Cannon game I'm still not sure what everything does or why it does it. Darren I tried looking for your template but couldn't find it on DPA... Is it not available anymore?

    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!
  • arcticsunrisearcticsunrise Member Posts: 159
    UtopianGames said:
    Nice tutorial, you could also recycle the trial like we did in our angry birds template (no spawning).



    Darren.

    did this template get produced for people to buy Darren ?

    image

  • lildragnlildragn Member Posts: 105
    Anyone? I'm not too sure what "game.trails to keep?" is for and why the actors require their own attributes. Just a bit confused on that.

    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
  • lildragnlildragn Member Posts: 105
    Ok, so after spending a day and some trying to figure out a simple way to implement this, I finally got it to work. It's basic but works I guess.

    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
  • JoeMeisterJoeMeister Member Posts: 602
    UtopianGames said:
    Nice tutorial, you could also recycle the trial like we did in our angry birds template (no spawning).



    Darren.

    Darren is this template still available?
    Can't find it anywhere.

    Cheers

    image

Sign In or Register to comment.