dsb_mac Posted June 16, 2016 Share Posted June 16, 2016 Hi I'm following the convention in this example. I couldn't figure out how to add a child sprite to it from within the constructor. I would appreciate it if someone could enlighten me. Link to comment Share on other sites More sharing options...
eddieone Posted June 16, 2016 Share Posted June 16, 2016 hmm something like this maybe var thing = game.make.sprite(0, 0, 'spriteName'); this.addChild(thing); I never actually tried this method. Instead I prefer constructor class that have a sprite as a child. Link to comment Share on other sites More sharing options...
dsb_mac Posted June 17, 2016 Author Share Posted June 17, 2016 Thanks I tried it and I see the sprite in the children but it's not visible on screen. Also what's the way you would do it? Link to comment Share on other sites More sharing options...
eddieone Posted June 17, 2016 Share Posted June 17, 2016 If you post your code, we could maybe see the issue. I use constructors var thing = function(game) { this.sprite = game.add.sprite(0, 0, 'thing'); this.update = function() { this.sprite.x++; } }; // in your main game area function create() { this.thing = new thing(game); } function update() { this.thing.update(); } Link to comment Share on other sites More sharing options...
dsb_mac Posted June 19, 2016 Author Share Posted June 19, 2016 Thanks. I figured it out! It wasn't showing before because there was another sprite blocking it in the order. Link to comment Share on other sites More sharing options...
Recommended Posts