# Difference between classes

**URL:** <https://phaser.discourse.group/t/difference-between-classes/7917>\
**Category:** Phaser 3\
**Created:** [October 23, 2020, 9:50pm UTC](https://phaser.discourse.group/t/difference-between-classes/7917 "2020-10-23T21:50:15Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![rawelja](https://yyz2.discourse-cdn.com/free1/user_avatar/phaser.discourse.group/rawelja/32/4240_2.png) [@rawelja](https://phaser.discourse.group/u/rawelja)\
**Post date:** [October 23, 2020, 9:50pm UTC](https://phaser.discourse.group/t/difference-between-classes/7917/1 "2020-10-23T21:50:15Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![samme](https://yyz2.discourse-cdn.com/free1/user_avatar/phaser.discourse.group/samme/32/5275_2.png) [@samme](https://phaser.discourse.group/u/samme)\
**Post date:** [October 24, 2020, 2:36am UTC](https://phaser.discourse.group/t/difference-between-classes/7917/2 "2020-10-24T02:36:49Z")

</div>

[Phaser.Physics.Arcade.Sprite](https://photonstorm.github.io/phaser3-docs/Phaser.Physics.Arcade.Sprite.html) 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?

---

<div class="post-metadata">

**Author:** ![rawelja](https://yyz2.discourse-cdn.com/free1/user_avatar/phaser.discourse.group/rawelja/32/4240_2.png) [@rawelja](https://phaser.discourse.group/u/rawelja)\
**Post date:** [October 24, 2020, 8:43am UTC](https://phaser.discourse.group/t/difference-between-classes/7917/3 "2020-10-24T08:43:10Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![samme](https://yyz2.discourse-cdn.com/free1/user_avatar/phaser.discourse.group/samme/32/5275_2.png) [@samme](https://phaser.discourse.group/u/samme)\
**Post date:** [October 24, 2020, 4:11pm UTC](https://phaser.discourse.group/t/difference-between-classes/7917/4 "2020-10-24T16:11:36Z")

</div>

If you’re extending a game object class then you need to call `this.add.existing(…)` somewhere, yes.

---

<div class="post-metadata">

**Author:** ![rawelja](https://yyz2.discourse-cdn.com/free1/user_avatar/phaser.discourse.group/rawelja/32/4240_2.png) [@rawelja](https://phaser.discourse.group/u/rawelja)\
**Post date:** [October 24, 2020, 9:33pm UTC](https://phaser.discourse.group/t/difference-between-classes/7917/5 "2020-10-24T21:33:10Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![samme](https://yyz2.discourse-cdn.com/free1/user_avatar/phaser.discourse.group/samme/32/5275_2.png) [@samme](https://phaser.discourse.group/u/samme)\
**Post date:** [October 24, 2020, 11:15pm UTC](https://phaser.discourse.group/t/difference-between-classes/7917/6 "2020-10-24T23:15:50Z")

</div>

> [@rawelja](#):
>
> Problem is now that when i call ‘this.setVelocityX’ it in update function to move player it says cant set on null.

You need to do `this.physics.add.existing(…)` or `this.physics.enable(…)`.
