Last active
July 6, 2019 02:27
-
-
Save thedrint/fd2936e5a3fbaf6c5a34bc34a72f82c1 to your computer and use it in GitHub Desktop.
Example of bug in Phaser3 nested containers
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var config = { | |
type: Phaser.AUTO, | |
parent: 'phaser-example', | |
width: 640, | |
height: 480, | |
scene: { | |
create: create, | |
} | |
}; | |
var parentContainer, anotherParentContainer, childContainer; | |
var parentBounds, anotherParentBounds; | |
var graphics; | |
var game = new Phaser.Game(config); | |
function create () | |
{ | |
graphics = this.add.graphics(); | |
parentContainer = this.add.container(128, 128); | |
var circle = this.add.ellipse(0, 0, 128, 128, 0x00ff00); | |
parentContainer.add(circle); | |
var line = this.add.line(0,0,0,0,64,0, 0x0000ff); | |
// line.setOrigin(0); | |
childContainer = this.add.container(0, 0); | |
childContainer.add(line); | |
parentContainer.add(childContainer); | |
anotherParentContainer = this.add.container(480, 256); | |
var anotherCircle = this.add.ellipse(0, 0, 128, 128, 0x006600); | |
anotherParentContainer.add(anotherCircle); | |
var anotherLine = this.add.line(0,0,0,0,64,0, 0x0000ff); | |
// line.setOrigin(0); | |
anotherParentContainer.add(anotherLine); | |
parentBounds = parentContainer.getBounds(); | |
anotherParentsBounds = anotherParentContainer.getBounds(); | |
graphics.clear(); | |
graphics.lineStyle(1, 0xff0000); | |
graphics.strokeRectShape(parentBounds); | |
graphics.lineStyle(1, 0xffff00); | |
graphics.strokeRectShape(anotherParentsBounds); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment