![]()
Code dans la première image clé sur la scène (AS3) Un clip pacit qui contient un clip pacman et un clip ghost // récupère la position du pacman var posx = pacit.pacman.x; var posy = pacit.pacman.y; // récupère la position du ghost var pos2x = pacit.ghost.x; var pos2y = pacit.ghost.y; pacit.ghost.x = 130; //pacit.ghost.y = pacit.ghost.height; function bouge(evt:Event):void { // interpolation de mouvement de pacman pacit.pacman.x += 5; // si pacman atteint le bord droit de la scène, il réaparrait de l'autre côté if( pacit.pacman.x >= stage.stageWidth ) { pacit.pacman.x = posx; pacit.pacman.y = posy; pacit.ghost.x = pos2x; pacit.ghost.y = pos2y; } // si pacman touche ghost, alors ghost se déplace if(pacit.pacman.hitTestObject(pacit.ghost)) { pacit.ghost.y = pacit.ghost.y + 25; } } addEventListener(Event.ENTER_FRAME,bouge); Exemple : Exemple réalisé en collaboration avec Matthieu et Xavier le 8 mars 2011 |