Can someone explain me difference between:
Phaser.GameObjects.Sprite and Phaser.Physics.Arcade.Sprite?
How can i know which one to use??
Or is there any more sprite clases that i can use
Phaser.Physics.Arcade.Sprite has some extra physics methods.
You don’t usually use either class directly. Instead you call this.add.sprite(…)
or this.physics.add.sprite(…)
.
Are you using Arcade Physics? Do you want to use physics on this sprite?
Yes i want.
I want to create new class that extends one for physics so i can create player objects and move them for RPG.
So for every this.physics.add.sprite i need to call add.existing after creating?
And if i am correct i must use physics.add onr because if i want collision to layers, etc?
Thanks in advance
If you’re extending a game object class then you need to call this.add.existing(…)
somewhere, yes.
I created class like this: export default class Player extends Phaser.Physics.Arcade.Sprite
and created this.player = new Player({scene: this,x:150, y:150, texture: ‘iddle’,frame: ‘survivor-idle_rifle_0’});
Problem is now that when i call ‘this.setVelocityX’ it in update function to move player it says cant set on null.
should i enable body, add existing or something or ‘Arcade.Sprite’ so i can move it with keyboard?
Should i add some code or i am missing something?
You need to do this.physics.add.existing(…)
or this.physics.enable(…)
.