Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ////////////////////////////////////////////////////////////////////////////////
- // VARIABLES //
- ////////////////////////////////////////////////////////////////////////////////
- var scene = Game.getCurrentScene("map_test");
- var joueur = scene.getGameObject("Joueur");
- ////////////////////////////////////////////////////////////////////////////////
- // COMPORTEMENT DE L'OBJET //
- ////////////////////////////////////////////////////////////////////////////////
- var comportement = new SingleBehavior({
- loop: function(objet){ // A chaque image, cette fonction se lance et met à jour l'objet
- // En fonction des touches enfoncées à chaque image, je déplace (ou non) l'objet en question
- if(Input.keyIsDown("left")) objet.setAnimation("left") , objet.getPosition().substractX(5);
- if(Input.keyIsDown("right")) objet.setAnimation("right") , objet.getPosition().addX(5);
- if(Input.keyIsDown("up")) objet.setAnimation("up") , objet.getPosition().substractY(5);
- if(Input.keyIsDown("down")) objet.setAnimation("down") , objet.getPosition().addY(5);
- }
- });
- // J'applique le comportement sur mon objet
- joueur.setBehavior(comportement); // LERREUR VIENT DE SE FOUTUE ENDROIT DE **** lol
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement