Game Development Reference
In-Depth Information
if (_selectedCards[0].cardNumber == _selectedCards
[1].cardNumber) {
_cardList.splice(_cardList.indexOf
(_selectedCards[0]),1);
_cardList.splice(_cardList.indexOf
(_selectedCards[1]),1);
TweenMax.to(_selectedCards[0], 1,
{ rotationZ:180, ease:Elastic.easeOut });
TweenMax.to(_selectedCards[1], 1,
{ rotationZ:-180, ease:Elastic.easeOut });
} else {
flipCard(_selectedCards[0], false);
flipCard(_selectedCards[1], false);
}
_selectedCards[0] = null;
_selectedCards[1] = null;
activateCards();
}
if (!_cardList.length) {
trace(
"
WON GAME
"
);
}
}
The final method in the Memory class is checkCards . It looks at
the _selectedCards list and checks to see if they have the same card
number. If the cards are not a match, it flips them back over. If
they are a match, they are removed from the main card list and
have a final tween run on them. This tween uses Elastic easing to
spin the cards with a rubber-band-like motion. Once the entire
card list vector is empty, the game has been won.
Obviously, the tweens I chose to use here are largely arbitrary.
One of the great things about TweenMax is how easy it is to
change the values to experiment with different equations and tim-
ing. We are also not limited to simple position, rotation, and scale
tweens. TweenMax has support for color and filter animation
effects as well, so you can really go wild experimenting, and the
syntax is still very straightforward. Feel free to explore the full
library with this game example.
Summary
However, if you ultimately choose to execute animation in your
game, make sure you consider how it affects the gameplay and
what is most appropriate for the subject matter. A game that is
intended for older adults or those who have vision difficulties
should have more subtle, smooth animation to not become
Search Nedrilad ::




Custom Search