Jump to content

this.game.input.onDown not working within the bounds of the game


mrbird
 Share

Recommended Posts

Hello there,

I am working on game part of which is beyond the constrains of the initial screen. So let's say that dimension of the screen is 800x600, but my game bounds are 3000x600.

I have camera locked on my character and I should be able to move it around by taping on the screen.

The part that does not seem to be working is that the tap beyond 800x600 does not seem to be registered and if it is character does not seem to move beyond that point.

I do not understand quite why.

var game = new Phaser.Game(800, 600, Phaser.AUTO, 'phaser-example', { preload: preload, init: init, create: create });

  
function preload() {
this.load.image('background', 'assets/images/background.png');
this.load.image('bird', 'assets/images/bird.png');
}



function init() {
this.scale.scaleMode = Phaser.ScaleManager.NO_SCALE;
this.game.physics.startSystem(Phaser.Physics.ARCADE);
//this.game.physics.arcade.gravity.y = 1000;
this.game.world.setBounds(0,0,3000,600);
} 



function create() {
this.background = this.game.add.tileSprite(0, 0, 3000, 600, 'background');
this.game.input.onDown.add(moveCharacter, this);
this.bird = this.game.add.sprite(800,120, 'bird');
this.bird.anchor.setTo(0.5);
this.camera.follow(this.bird, Phaser.Camera.FOLLOW_LOCKON); 
}




function moveCharacter(pointer) {
this.isMoving = true;
var duration = (this.game.physics.arcade.distanceToPointer(this.bird, pointer) / 300) * 1000;
tween = this.game.add.tween(this.bird).to({ x: pointer.x, y: pointer.y }, duration, Phaser.Easing.Linear.None, true);
tween.onComplete.add(this.moveCharacterComplete, this);
}


function moveCharacterComplete() {
this.isMoving = false;
//this.bird.animations.stop();
}

 

phaser3.jpeg

Link to comment
Share on other sites

@samme Hello. Thank you for your reply. Yes it is moving but if you observe it for a moment you will see the bird is moving only up to a point which is the 800px. After that point it is not moving any more so in effect the bird is not able to go over and move in those 2200px (world bound is 3000px). So no matter what you do, clicking beyond the 800x600 window the bird won't move there (it will but only to the point it reaches the 800px). I even set the bird to start at 800px position so it is more apparent that it can only move to the left but not to the right. Is this a bug, or is there something I missed to declare for the touch to work on the world bound rather than on the variable game - devfault 800x600 window.

Thank you

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...