flagga Posted February 21, 2017 Share Posted February 21, 2017 I am creating a game like this: http://www.1001spiele.de/aktion/az-tanks But I am a noob in Phaser - I programm with pelles c in school, so this does not help me much. I already created a tank and managed it to code the controls. Now I am trying to use weapons. I used the example http://phaser.io/examples/v2/weapon/single-bullet but it doesn't work: Here is a part of my code (full code uploded): function create{ player1 = game.add.sprite(32, game.world.height - 150, 'player1'); player1.anchor.setTo(0.5,0.5); game.physics.p2.enable(player1, false); game.physics.arcade.enable(player1); player1.body.collideWorldBounds = true; cursors = game.input.keyboard.createCursorKeys(); w = game.input.keyboard.addKey(Phaser.Keyboard.W); a = game.input.keyboard.addKey(Phaser.Keyboard.A); s = game.input.keyboard.addKey(Phaser.Keyboard.S); d = game.input.keyboard.addKey(Phaser.Keyboard.D); spacebar = game.input.keyboard.addKey(Phaser.Keyboard.SPACEBAR); var weapon = game.add.weapon(30, 'bullet'); weapon.bulletKillType = Phaser.Weapon.KILL_WORLD_BOUNDS; weapon.bulletAngleOffset = 90; weapon.bulletSpeed = 400; weapon.fireRate = 60; weapon.trackSprite(player1, 14, 0); } function update{ if (spacebar.isDown){ weapon.fire(); } } example.txt Link to comment Share on other sites More sharing options...
Recommended Posts