I'm working on creating a simple shell game but it's turning out to not be so simple. I want to shuffle the 3 shells swapping position with 2 at a time.
For the first couple of shuffles it's fine but after that they seem to get confused and it looks like more than 2 are being shuffled at once.
function initShuffle(event:MouseEvent):void{
running = 0;
shuffle(Globals.ShuffleCount);
}
function shuffle(times:int):void{
Globals.IsShuffling = true;
this.times = times;
var s1:int = Globals.getRandomShellIndex(-1, Globals.Shells.length);
var s2:int = Globals.getRandomShellIndex(s1, Globals.Shells.length);
shellTmp1 = Globals.Shells[s1];
shellTmp2 = Globals.Shells[s2];
shellTmp2.parent.setChildIndex(shellTmp2, shellTmp2.parent.numChildren - 1);
var x1 = shellTmp1.x;
var x2 = shellTmp2.x;
finishX1 = x2;
finishX2 = x1;
ss2(shellTmp1, finishX1, true);
ss2(shellTmp2, finishX2, false);
}
function ss2(shellObj:MovieClip, finishX:Number, use1:Boolean){
TweenLite.to(shellObj, Globals.speed, {x: finishX, onComplete:tweenComplete} );
}
function tweenComplete():void{
if (--this.times > 0){
shuffle(this.times);
}
Globals.IsShuffling = false;
}
Ideally I would love it if I could get the Z to change as it moves on the X and than go back to it's original Z before it reaches the final X position. This would make it look like the shell in front is closer and the shell moving the opposite way is further.
Thanks for any help,
Joe