Jump to content

Search the Community

Showing results for tags 'angletopointer'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • HTML5 Game Coding
    • News
    • Game Showcase
    • Facebook Instant Games
    • Web Gaming Standards
    • Coding and Game Design
    • Paid Promotion (Buy Banner)
  • Frameworks
    • Pixi.js
    • Phaser 3
    • Phaser 2
    • Babylon.js
    • Panda 2
    • melonJS
    • Haxe JS
    • Kiwi.js
  • General
    • General Talk
    • GameMonetize
  • Business
    • Collaborations (un-paid)
    • Jobs (Hiring and Freelance)
    • Services Offered
    • Marketplace (Sell Apps, Websites, Games)

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


Website URL


Twitter


Skype


Location


Interests

Found 2 results

  1. Hi, I'm currently making a litlle top-down shooter game with Phaser. I'm using the method bellow to aim towards the mouse's position. sprite.rotation = game.physics.arcade.angleToPointer(sprite); This work very well, but I would like to allow the player to zoom in and out. I was following this idea : http://jsfiddle.net/NMNJ7/25/ which use the game.world.scale.set() method; But when I change the world's scaling, the angleToPointer() method is completly lost and it's impossible to aim. You can try this little exemple I've made to understand what goes wrong : https://jsfiddle.net/TomLeGrand/uh7d10eu/127/ Do someone has an idea to fix this? Thanks for you futur help
  2. Hey guys, I'm newbie of Phaser so I hope you don't get mad for my simple problem. My code simply moves a tank sprite around the screen, along with rotating its barrel (its childSprite) by using the mouse position...that's it. The problem is the barrel: its rotation is completely broken! I used angleToPointer() directly from Phaser.io documentation but I can't find the solution of this problem. video: broken_rotation.wmv var game = new Phaser.Game(800, 600, Phaser.CANVAS, 'phaser-example', { preload: preload, create: create, update: update, render: render }) var player; var barrel; function preload() { game.load.image('tank', 'assets/PNG/Tanks/tankBlue_outline.png'); game.load.image("barrel", "assets/PNG/Tanks/barrelBlue_outline.png"); } function create() { player = game.add.sprite(200, 200, 'tank'); player.scale.setTo(0.5, 0.5); player.anchor.setTo(0.5, 0.5); barrel = new Phaser.Sprite(this.game, 0, 0, "barrel"); player.addChild(barrel); barrel.anchor.setTo(0,0.5) } function update() { if (game.input.keyboard.isDown(Phaser.KeyCode.W)) { speed = 3 var velocityX = Math.cos(player.angle * Math.PI / 180) * speed; var velocityY = Math.sin(player.angle * Math.PI / 180) * speed; player.x += velocityX; player.y += velocityY; } if (game.input.keyboard.isDown(Phaser.KeyCode.D)) { player.angle += 1; } if (game.input.keyboard.isDown(Phaser.KeyCode.A)) { player.angle -= 1; } if (game.input.keyboard.isDown(Phaser.KeyCode.S)) { speed = -2; var velocityX = Math.cos(player.angle * Math.PI / 180) * speed; var velocityY = Math.sin(player.angle * Math.PI / 180) * speed; player.x += velocityX; player.y += velocityY; } //barrel.angle += 1 the automatic rotation works perfectly!... barrel.rotation = game.physics.arcade.angleToPointer(barrel); // ...but not the input one sadly } function render() { game.debug.spriteInfo(barrel, 20, 32); }
×
×
  • Create New...