Jump to content

sprite move on the path...


makis
 Share

Recommended Posts

var config = {
    type: Phaser.AUTO,
    width: 800,
    height: 600,
    scene: {
        preload: preload,
        create: create

    }
}

var game = new Phaser.Game(config);

function preload() {
    this.load.image('rocket','rocket.png')
}

function create() {
 //var rocket =  this.add.sprite(100, 400, 'rocket');
 //rocket.setRotation(-0.2);
    var path1 = new Phaser.Curves.Path(100, 400).splineTo([200,250,400,280])
    var graphics = this.add.graphics();

    graphics.lineStyle(1, 0xffffff, 1); //what is 1, , 1

    path1.draw(graphics, 328); //what is 328

   rocket =  this.add.follower(path1, 0, 0, 'rocket'); // what is 0, 0
 
    rocket.startFollow({
        positionOnPath: true,
        duration: 1000,

        repeat: -1,
        rotateToPath: true,
        verticalAdjust: true
    });
}
 // how to make the rocket points to the path?

How to make rocket point to path?

What is ... see the comments in code snippet?

FROM  PHASER 3 EXAMPLES

rocket.jpg

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

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