Jump to content

Create Sprite In Simple Class


Aram
 Share

Recommended Posts

Hi all,

Could someone tell, is it possible to create sprite not in Scene class? For example my scene class has obj of ClassA, how can I create sprite in classA?

Do I have to keep scene Ref in ClassA and then create through it?

Thank you!

Link to comment
Share on other sites

A Sprite's constructor looks like this (https://github.com/photonstorm/phaser/blob/master/src/gameobjects/sprite/Sprite.js#L77)

function Sprite (scene, x, y, texture, frame)

 

So wherever you create your Sprite, you'll need to pass in a reference to the scene. This could be anywhere in your codebase, as long as you are able to have a reference to that scene.

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

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