wusiquan Posted June 1, 2018 Share Posted June 1, 2018 // Scene { create: function() { // I add a group let titleGroup = this.add.group() // add something... let title = titleGroup.create(0, 100, 'title') let bird = titleGroup.create(100, 100, 'bird') // now I need adjust the group to appropriate position // compile Error! titleGroup.getChildren.forEach(child => { child.setPosition(50, 20) }) // comment last few lines! // ok~~ titleGroup.getChildren.forEach((child: Phaser.GameObjects.Sprite)=> { child.setPosition(50, 20) }) } } So, getChildren seems return something like <T> extends GameObjects would be better?? Link to comment Share on other sites More sharing options...
wusiquan Posted June 1, 2018 Author Share Posted June 1, 2018 Just now, wusiquan said: // Scene { create: function() { // I add a group let titleGroup = this.add.group() // add something... let title = titleGroup.create(0, 100, 'title') let bird = titleGroup.create(100, 100, 'bird') // now I need adjust the group to appropriate position // compile Error! titleGroup.getChildren.forEach(child => { child.setPosition(50, 20) }) // comment last few lines! // ok~~ titleGroup.getChildren.forEach((child: Phaser.GameObjects.Sprite)=> { child.setPosition(50, 20) }) } } So, getChildren seems return something like <T> extends GameObjects would be better?? code above, getChildren forget brackets, sorry Link to comment Share on other sites More sharing options...
Recommended Posts