Search the Community
Showing results for tags 'xy'.
-
Hi all, Currently I try to rotate the game 90 degree to meet the portrait mode for my [landscape] game, I used other's solution to rotate all display object by this.game.scale.setGameSize(, ; and Phaser.World.prototype.displayObjectUpdateTransform = function() { if(!this.game.scale.correct) { this.x = this.game.camera.y + this.game.width; this.y = -this.game.camera.x; this.rotation = Phaser.Math.degToRad(Phaser.Math.wrapAngle(90)); } else { this.x = -this.game.camera.x; this.y = -this.game.camera.y; this.rotation = 0; } PIXI.DisplayObject.prototype.updateTransform.call(this); }; now all display object are rotated, but the pointer are not rotate, so when I want to do something with activePointer like: calculation with the mouse position drag and drop logic the x, y are reversed. So I want to know is there any good solution to switch the x, y of the pointer, thx.
-
How do I simply set an x, y coordinate on an arcade body? Specifically, I'm trying to set the starting position of a player after the sprite is created and physics enabled, but before there is a physics update. When I do so as below, the body ignores the new setting and opens with the sprite at the initial dummy coordinates. I have arranged my code like this: // Map inherits from Tilemap and creates all of the layersvar map = new Map(this.game, 'map'); // Player inherits from Sprite// 0, 0 is the initial coordinate// the constructor enables physics on the bodyvar player = new Player(this.game, 0, 0, 1);// This is so that map can insert the player into the proper// group index and location.map.addPlayer(player);in Map I have:function addPlayer(player){this.game.world.addAt(player, this.PLAYER_LAYER);player.body.moves = false; // <-- doesn't seem to matter whether this is set or notplayer.body.x = this.START_X;player.body.y = this.START_Y;player.body.reset(this.START_X,this.START_Y); // <-- doesn't matter whether I set it this way or not}How can I move the sprite to the proper starting coordinates?