Search the Community
Showing results for tags 'previous'.
-
Hi all. I have a problem with my game I can't understand. Here the code: function createTitleView() { //Creates title title = game.add.sprite(game.world.centerX, game.world.centerY-60, 'title'); title.anchor = new Phaser.Point(0.5,0.5); title.name= "title"; //Creates play button playBtn = game.add.sprite(game.world.centerX, game.world.centerY+60, 'playBtn'); playBtn.anchor = new Phaser.Point(0.5,0.5) playBtn.name = "play button"; //Creates game view titleView = game.add.group(); titleView.name = "title view"; titleView.add(title); titleView.add(playBtn); //Assigns event listener to play button playBtn.inputEnabled = true; playBtn.events.onInputDown.add(startGame, this);}function startGame() { // Creates the player gameView = game.add.group(); gameView.name = "game view"; unicorn = game.add.sprite(100, 100, 'unicorn'); unicorn.name = "unicorn"; gameView.add(unicorn); // Slides out the title view titleViewSlideOut = game.add.tween(titleView).to({y: -game.world.height}, 500, Phaser.Easing.Exponential.In, true); createGameView();}Now the fact is that the unicorn's position is relative to the playerBtn and moves with it. Why is that if they're on two separate groups? Here is a dump of the titleView Node | Next | Previous | First | Last ---------- | ---------- | ---------- | ---------- | ---------- group | title | credits button | group | play button > title | play button | group | title | title play button | group | title | play button | play button and here is a dump of the game view Node | Next | Previous | First | Last ---------- | ---------- | ---------- | ---------- | ---------- group | unicorn | play button | group | unicorn > unicorn | - | group | unicorn | unicorn As you can see the play button is somehow part of the gameView. How could it be possible?