Search the Community
Showing results for tags 'moveToPointer'.
-
Hi there, Before reading, I want you to know that you can test my little code here : https://jsfiddle.net/TomLeGrand/meL44k5k/ (Arrows to move the player and mousse to aim in a direction) So, I had some problems using the camera.follow (), moveToPointer () and world.scale.set () functions simultaneously. It seems that the world's scaling influence the x and y properties of world's object (like the camera, the input, etc...). To be more specific, I can't use the camera.follow(player), because the player get out from the camera at some point. The only solution I found was to set the x and y camera's values in the update function but now I don't know how I can get a "smooth effect" without using the camera.follow() function. The moveToPointer() method react badly too, the farthest I go, the worst It get, even with game.input.scale.set(). I'll be glad if you can help me to fix the camera and the moveToPointer() methods
-
Hi everybody. I need help in my little game. My problem is, how i can move the player using game.physics.arcade.mo? The code in red coler doesn't works. Why? I'm using Intel XDK. Thanks. BasicGame = { };BasicGame.Game = function (game) { };BasicGame.Game.prototype = { init: function () { this.input.maxPointers = 1; this.stage.disableVisibilityChange = true; this.scale.scaleMode = Phaser.ScaleManager.SHOW_ALL; this.scale.pageAlignHorizontally = true; this.scale.pageAlignVertically = true; this.scale.forceOrientation(true, false); this.scale.setResizeCallback(this.gameResized, this); this.scale.setScreenSize(true); this.scale.refresh(); this.game.physics.startSystem(Phaser.Physics.ARCADE); }, preload: function () { this.load.image('bg', 'asset/bg-space-easy.png'); this.load.image('player', 'asset/player.png'); }, create: function() { this.bg = this.game.add.image(this.world.centerX, this.world.centerY, 'bg'); this.bg.anchor.setTo(0.5, 0.5); this.player = this.game.add.image(10, 10, 'player'); this.player.anchor.setTo(0.5, 0.5); this.input.onDown.add(touchCoordinatesDebug, this); function touchCoordinatesDebug(pointer) { this.game.debug.inputInfo(32, 32); this.game.debug.spriteInputInfo(sprite, 32, 130); this.game.debug.pointer(this.game.input.activePointer); } }, update: function() { this.game.physics.arcade.enable(this.player); this.player.body.velocity.y += 50; if(this.game.physics.arcade.distanceToPointer(this.player, this.input.activePointer) > 8) { this.game.physics.arcade.moveToPointer(this.player, 300); } else { this.player.body.velocity.set(0); } }, gameResized: function (width, height) { }};
-
Hey all, Brand new here and I am having an issue creating a dragging object effect that lags behind the mouse. I have tried programming a draggable object manually but that didn't go so well so I looked into the moveToPointer function under arcade physics. The issue is, it seems to have a bug where the object you are moving bounces back and forth when extremely close to the pointer in question. See this example here: http://phaser.io/examples/v2/input/follow-mouse I assume this is occurring because the object moves past the pointer by a few pixels in one update and then in the very next its velocity gets flipped to move it back towards the pointer. Does anyone have any recommendations on how to prevent/fix this?
-
Hi, I'm using game.physics.arcade.moveToPointer to make a bullet fly where I click: game.physics.arcade.moveToPointer(bullet, bulletSpeed); But I want my character to recoil and fly backwards when he shoots. I'm trying it like so: angleToPointer = game.physics.arcade.angleBetween(player, game.input); game.physics.arcade.velocityFromAngle(angleToPointer -180, 300, player.body.velocity); But it's not working. Any help? Thanks
-
Hi, I was just wondering if there was anyway to use the moveToPointer function when using P2 physics or if there was anything similar to that. I'm trying to get bullets to move to the user's pointer. Thanks!