Jump to content

group getChildren returns GameObjects.GameObject[]


wusiquan
 Share

Recommended Posts

 


// 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

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

 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...