Thursday, May 15, 2008

Tweener for games: Updating Amounts

Following up on the Tweener for games tutorials, this time we will see how to update amounts gradually using Tweener to make them look nice & smooth.

As an example we can see my game GAIA - Guess Who? where the score is updated gradually instead of in one step (immediately) adding more to the user's experience and making the game more playable and enjoyable. Trust me, these little details can make a difference ;)

Update amounts gradually using Tweener:
What I've got on stage is a dynamic textfield with instance name "txtScore".
To give it a value, we declare a variable called myScore:

var myScore : Number = 100;
txtScore.text = myScore;

If you run the movie, your txtScore shows 100.
Nothing exiting I know... :P

Because we need to update this amount when a certain event happens, then we add a button, we will call it mcAddBonus.
Now let's use tweener to update the score adding a 50 points bonus:

import caurina.transitions.Tweener;

var myScore : Number = 100;
txtScore.text = myScore;

mcAddBonus.onRelease = function() : Void
{
Tweener.addTween(this._parent, {myScore:myScore + 50, time:1, onComplete:function() { txtScore.text = Math.round(myScore); }});
}


Testing the movie, whenever we press our button after a second myScore updates by 50.
Still nothing special :(
but, how about if we use the tweener onUpdate parameter instead of onComplete?
the onComplete only updates our score when the tween has finished but as we saw on the previous example, onUpdate updates the value gradually before the tween finishes.
Let's change the code:

import caurina.transitions.Tweener;

var myScore : Number = 100;
txtScore.text = myScore;

mcAddBonus.onRelease = function() : Void
{
Tweener.addTween(this._parent, {myScore:myScore + 50, time:1, onUpdate:function() { txtScore.text = Math.round(myScore); }});
}



Sweet!
I must say I love Tweener, is a great tool :)
and this is the example:






salut!

Saturday, May 10, 2008

Flash Games Contest: 5th place

Gaia - Guess Who?
To be honest I was a bit too positive about this one and I was expecting to get one of the first 3 prizes, however, there were 200+ games and many of them were really good, so 5th place is not bad at all ;)

The contest: MochiAds & Gaia Online - Become a Rock Star.

Actually there were two categories:
- Rock Star Winners
- Gaia Audience Prizes

and my game Gaia - Guess Who? won the 5th place of the Gaia Audience Prizes category.

I must say my game Gaia - Guess Who? is not the best but I was positive because I actually participated with 3 games altogether:
- Gaia - Guess Who?
- Save the Ants
- Pawel & the Teutonic Castle
Anyway, I'm really happy I've won a prize on this contest :)

For more info check out the "Become a Rock Star" Flash Game Contest winners' page.

salut!