• Content count

  • Joined

  • Last visited

  1. How do i add health to a character

    Download the file HealthMeter.js and put the file in your game (dont remember to add the file html //// script src="../healthMeter.js"). you can see a exemple on gitHub , https://github.com/matthiaswh/phaser-health-meter/blob/master/examples/example.js , line (79-92) .
  2. Stop animation

    hello, I need your help guy, i would create an animation with my character. When i push left click (mouse), the animation start but she is infinite. How stop my animation? my code: create: function() { this.player.animations.add('atk', [529, 532, 535, 538, 541], 10); this.game.input.onDown.add(this.atk, this); }, atk: function(){ this.atkBool = true; }, update(){ if (this.game.input.onDown && this.atkBool == true){ var anim = this.player.animations.play('atk'); } I want just 1 loop so stop animation after my "541" frames. Sorry for my english langage. I hope you can help me. Good day
  3. Attack with left click

    i can get inside the function but the animation doesn't work. I haven't error message in console.
  4. Attack with left click

    Hello everyone, I need your help , i try create a "rpg game" . I want use the left click (mouse1) for auto atk with my hero. my code: create: function(){ this.player.animations.add('atk', [529, 532, 535, 538, 541], 10, true); } update: function(){ if(game.input.activePointer.isDown){ this.player.animations.play('atk'); } with this code i need to keep my left click to push for see the action. And i want just to push 1 time. Sorry my english is very bad.
  5. Input keyboard SPACEBAR

    Loool, you said right, it was off screen beause i have a big world. thx man
  6. Input keyboard SPACEBAR

    Hello everyone, can you told me why my code is not working ? i don't understand why is not working, i got inspired with this : https://phaser.io/examples/v2/input/keyboard-hotkeys my code: function preload(){ game.load.image('bulleRpg', 'assets/bulleRpg/bulleRpg.png'); } var spaceKey; function create(){ spaceKey = game.input.keyboard.addKey(Phaser.Keyboard.SPACEBAR); spaceKey.onDown.add(drawBulleRpg, this); } function drawBulleRpg() { game.add.sprite(game.world.centerX + 250, game.world.centerY + 150, 'bulleRpg'); } i want just display an image when i press the spacebar. Thx lot of
  7. display an element of a tileset

    thx you man ^^
  8. display an element of a tileset

    Hello everyone, I need help, i want display an element of a tileset, but i don't understand how to do that. function preload() this.game.load.image('stone', 'assets/tiles/tiless.png'); function create() this.stone = this.game.add.image(720, 78, 'stone'); i guess , i need a key or other but i don't understand how write and found this key. my tileset is 32*32
  9. help me pls, tilemaps collision

    My problem is resolved , i need to write: map.setCollisionBetween(234, 235, true, layer2) ===> i's important to write true and layer2 If someone need this answer.
  10. help me pls, tilemaps collision

    but I think is not my problem because my character can run and stop. I dont know why, i can collide my layer( who is my background) but i cant collide my second layer (tree, montain..)
  11. help me pls, tilemaps collision

    Hello everyone, I am beginner with phaser, i am French and my english is not very nice. I need your help, i am blocked on a collide function. I want my character to collide with my second layer (tree, montain, statue..). (i use tiled map editor and export in json). my code : function preload: game.load.tilemap('map', 'assets/tilemaps/maps/map.json', null, Phaser.Tilemap.TILED_JSON); game.load.image('tiles', 'assets/tiles/tiles.png'); game.load.spritesheet('perso', 'assets/sprite/spritetest.png', 32, 47); function create : game.physics.startSystem(Phaser.Physics.ARCADE); map = game.add.tilemap('map'); map.addTilesetImage('tiles'); layer = map.createLayer('layer1'); layer2 = map.createLayer('layer2'); layer2.resizeWorld(); map.setCollisionBetween(0,2000); //PLAYER // ajout player et parametre player = game.add.sprite(250, 50, 'perso'); // We need to enable physics on the player game.physics.arcade.enable(player, Phaser.Physics.ARCADE); function update : game.physics.arcade.collide(player, layer2); i show an image for understand my problem. Thx to read my message