Jump to content

Callin' a method from a group


Recommended Posts

Hi everybody I'm trying to call a refresh class method from objects in a Phaser group. 


This method must call other methods which have to be update in the game loop, but I can't call it. 

I just tried to do it with the forEach method and also with a simple for loop, but it doesn't work and I got an "Uncaught TypeError: undefined is not a function". 

So I tried with bind() without success, because I don't understand how to call a class method from such a function.


Thanks for your help and please escuse my hella english, I'm french. 

// Rafraîchissementfunction update() {    // Tank     tank1.update();    // Bombes    bombs.forEach(function(item) {        item.refresh();     });} 

The other thing I tried with the same error : 

// Rafraîchissementfunction update() {    // Tank     tank1.update();    // Bombes    for (var i = 0; i < bombs.length; i++) {        bombs.getAt(i).refresh();    }}


Link to comment
Share on other sites


  • Recently Browsing   0 members

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