mercredi 25 décembre 2019

function referring to object doesn't remove it from stage

the function doesn't remove the object:

const app = new PIXI.Application({
  resizeTo: window
});

current_sprite = new PIXI.Sprite.from(`backgammon/dices/Alea_${user.cubes[index][0]}.png`);

current_sprite.delete = () => {
  console.log("current_sprite:");
  console.log(current_sprite);
  app.stage.removeChild(current_sprite);
}

meanwhile it does recognize the object. My main question is if this syntax is correct in javascript? can I refer in a block to the object trying to define a property of his? or should I use the e.target syntax?

definition of the array: other_cubes[index] = [current_sprite, next_sprite]; and next_sprite is identical to current. the call is: other_cubes[current.Inex_ToCube2][0].delete(); and the index is 5 - which makes sense; the array is built correctly becuase the printed output makes sense.





Aucun commentaire:

Enregistrer un commentaire