i am trying to get this wood to go up and down the screen but it only goes up… then keeps going up…
this is my code
class woodScene extends Phaser.Scene
{
constructor()
{
super("woodScene");
}
preload()
{
this.load.image('wood', 'wood.png');
}
create()
{
this.upDownWood = this.physics.add.sprite(515, 325, 'wood');
this.upDownWood.body.setImmovable(true);
this.upDownWood.body.setAllowGravity(false);
this.upDownWood.setVelocityY(-100);
}
update()
{
if (this.upDownWood.y == 580)
{
this.upDownWood.setVelocityY(-100);
}
if (this.upDownWood.y == 0)
{
this.upDownWood.setVelocityY(100);
}
}
}
it appears everything in the update function isnt working