Advertisement
Guest User

Untitled

a guest
Feb 6th, 2016
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.34 KB | None | 0 0
  1. ////////////////////////////////////////////////////////////////////////////////
  2. // VARIABLES //
  3. ////////////////////////////////////////////////////////////////////////////////
  4.  
  5. var scene = Game.getCurrentScene("map_test");
  6. var joueur = scene.getGameObject("Joueur");
  7.  
  8.  
  9. ////////////////////////////////////////////////////////////////////////////////
  10. // COMPORTEMENT DE L'OBJET //
  11. ////////////////////////////////////////////////////////////////////////////////
  12. var comportement = new SingleBehavior({
  13. loop: function(objet){ // A chaque image, cette fonction se lance et met à jour l'objet
  14.  
  15. // En fonction des touches enfoncées à chaque image, je déplace (ou non) l'objet en question
  16. if(Input.keyIsDown("left")) objet.setAnimation("left") , objet.getPosition().substractX(5);
  17. if(Input.keyIsDown("right")) objet.setAnimation("right") , objet.getPosition().addX(5);
  18. if(Input.keyIsDown("up")) objet.setAnimation("up") , objet.getPosition().substractY(5);
  19. if(Input.keyIsDown("down")) objet.setAnimation("down") , objet.getPosition().addY(5);
  20. }
  21. });
  22.  
  23. // J'applique le comportement sur mon objet
  24. joueur.setBehavior(comportement); // LERREUR VIENT DE SE FOUTUE ENDROIT DE **** lol
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement