nExt Posted May 9, 2014 Share Posted May 9, 2014 Hello i try display sprite in my game.. game.stage.backgroundColor = "1781A6";var logo = game.add.sprite(screen.width/2, game_height/2,'logo');..next i set time 3s add and display cloudthis.timer = this.game.time.events.loop(Phaser.Timer.SECOND * 3, add_cloud, this);.........function add_cloud(){ for(var i = 1; i<=5; i++){ var cloud = this.game.add.sprite(screen.width * Math.random(),game_height,'cloud'+ game.rnd.integerInRange(1,3)); cloud.body.gravity.y = - 30 }}.i want display cloud behind logo (as site : http://toastedware.com/) help me.. thank you ! Link to comment Share on other sites More sharing options...
stasuss Posted May 9, 2014 Share Posted May 9, 2014 logo.bringToTop(); nExt 1 Link to comment Share on other sites More sharing options...
nExt Posted May 9, 2014 Author Share Posted May 9, 2014 logo.bringToTop();write it on function update, not create ??? if i want create group : stars = game.add.group();and crete some star.. star= start.create(posX, posY, 'star'); can use function bringtoTop() to all star ??? thank you ! Link to comment Share on other sites More sharing options...
stasuss Posted May 9, 2014 Share Posted May 9, 2014 Yes, this method should be called on update.Yes, you can bring all the stars on top, but you can do this by bringing the whole group on top of the world.game.world.bringOnTop(yourGroupHere);The reason for this is that bringOnTop() brings the child to the top of the group. And as world is the group internally and every object is contained inside it, you can bring its children on the top. KevinnFtw 1 Link to comment Share on other sites More sharing options...
nExt Posted May 9, 2014 Author Share Posted May 9, 2014 Yes, this method should be called on update.Yes, you can bring all the stars on top, but you can do this by bringing the whole group on top of the world.game.world.bringOnTop(yourGroupHere);The reason for this is that bringOnTop() brings the child to the top of the group. And as world is the group internally and every object is contained inside it, you can bring its children on the top. i try method bringOnTop() but i error ? (underfine method bringOnTop()) i try bringToTop() for cloud then the result is : (logo is ok) Link to comment Share on other sites More sharing options...
stasuss Posted May 9, 2014 Share Posted May 9, 2014 and what is wrong? PS: don't you consider upgrading to Phaser 2? Link to comment Share on other sites More sharing options...
nExt Posted May 9, 2014 Author Share Posted May 9, 2014 and what is wrong? PS: don't you consider upgrading to Phaser 2?if change game.world.bringToTop('clouds') to game.world.bringOnTop('clouds'); on function update() in console (chrome) report : undefine is a not function (bringOnTop) i learn and download phaser from 2 weeks ago in main site of phaser.. i don't know my phaser is Phaser 2 or not .. i include only phaser.min.js in file index.html.. Link to comment Share on other sites More sharing options...
stasuss Posted May 9, 2014 Share Posted May 9, 2014 Sorry, my mistype The method is called bringToTop You can get the latest version here. Just download the zip file. Link to comment Share on other sites More sharing options...
nExt Posted April 17, 2015 Author Share Posted April 17, 2015 Sorry, my mistype The method is called bringToTop You can get the latest version here. Just download the zip file.thank ! Link to comment Share on other sites More sharing options...
ZoomBox Posted April 17, 2015 Share Posted April 17, 2015 I don't know about this phaser version but the best practice is to create a group in the order you want you sprites to display. Link to comment Share on other sites More sharing options...
Recommended Posts