-
Chapter 6
Posted on July 26th, 2009 6 commentsChapter 6 is about animation, both tweened and programmatic. First we cover how to do simple motion to control enemy ships in a shooter game. The second half of the chapter involves usage of the GreenSock Tweening Platform for doing animations that are not directly game mechanic-driven.
Unpaid plug: If you go on to use TweenLite/TweenMax, please contribute some amount of money to the project. Jack Doyle maintains and updates it well, mainly because others have given him incentive to do so through their donations. Let’s continue to support it as the standard tweening platform for AS3.
6 responses to “Chapter 6”
-
I cant seem to find the Memory game files for PC in the Chapter Files. Am I missing something?
-
If you grab the zip file on this page, it is in there. The Memory FLA is the file you’re looking for. It uses the two classes Memory and MemoryCard.
-
Stephen June 16th, 2010 at 18:04
Thanks for the great book! I’m having to convert the examples to flash player 9 as I go through the book since I’m working in CS3. In the Memory Card Game example I changed the vectors to arrays, but I’m getting errors with the TweenMax and am not sure why. The import paths to the classes are correct but am getting: Error #1069: Property rotationY not found on MemoryCardCS3 and there is no default value.
at gs::TweenLite/initTweenVals()
at gs::TweenMax/initTweenVals()
at gs::TweenLite/activate()
at gs::TweenLite$/updateAll() -
Hi Stephen,
It’s not a TweenMax error, misleading as that message is. The rotationY property is only available when publishing to Flash Player 10 (CS4), but TweenMax doesn’t do any kind of validation on the parameters you pass in. You can achieve a similar affect to what I’m doing simply by adjusting the scaleX property to make it look like the card is flipping. It’s not quite the same because it won’t have proper perspective, but for an exercise it’s certainly good enough. -
Chris I am trying to tweak the memory game to compare consecutive cards instead of similar: 0 & 1 match, 2 & 3 match, etc…
Any suggestions on how to change checkCards() to make that happen? I can do it logically in my head, but I don’t know how to code it.
Great book, it has solved lots of problems for my current project and sparked plenty of ideas for future projects!
-
So you want to pair cards based on whether they are next to each other, based on a zero index? Right now I do a comparison of the card numbers to see if they match:
if (_selectedCards[0].cardNumber == _selectedCards[1].cardNumber) {
What you’re wanting sounds more like this:
var index1:int = _cardList.indexOf(_selectedCards[0]);
var index2:int = _cardList.indexOf(_selectedCards[1]);
if (Math.floor(index1 / 2) == Math.floor(index2 / 2)) {
//some logic here
}
By dividing the index in the list by 2 and rounding down you’ll see that cards 0 and 1 will match, 2 & 3, etc. Make sense?
Leave a reply
-


