Sign in to follow this  
Aram

Create Sprite In Simple Class

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!

Share this post


Link to post
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.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.