Jump to content

Occasional Stutter with MoveTo function


DeusX
 Share

Recommended Posts

Hello,

I know this is my second Thread today but I found out about this forum today and I'm curious about the Problems I had while learning Phaser the past week, so sorry for that^^

My first game was a simple point&click game, where you could click an (moving) image & that image would appear somewhere new at random. Now the problem is that everytime I restart the scene (using this.scene.restart()) the object would start to stutter in the "new" Scene. The object always started in a random location and moved with moveTo(endX, endY, 100) to the other location.

Is this because of the moveTo function? Should I use another approach for moving the object? I can supply a code sample later on.

//startLocations and endLocations are Arrays containing random positions where the object
should start and where it should go to
create()
{
     this.player = this.physics.add.sprite(this.startLocationsX.pop(), this.startLocationsY.pop(),                 "coin");

     this.player.setCollideWorldBounds(true);
     this.player.setBounce(1);

     this.angle = this.physics.moveTo(this.player, this.endLocationsX.pop(), this.endLocationsX.pop(), 200);
}
//my config
const config = 
{
    type: Phaser.AUTO,
    width: window.innerWidth,
    height: window.innerHeight,
    fps: 60,
    scene : [Game],
    physics: 
    {
        default: 'arcade',
        arcade: 
        {
            gravity: { y: 0 },
        }
    },
}
//and a reset function for when to object was clicked
reset()
{
    this.scene.restart();
}

Thanks

 

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

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