Thao Cao Minh Posted September 20, 2019 Share Posted September 20, 2019 I have a problem while create a group, that i want to add parameter to the children of the group. I logged the group, it showed that it was a list of children. But the next line i tried to interate them to set property for its child, the length of list = 0; I don't know how to deal with this problem, so... Thank you for reading this. This is my code: // this is in the GameScene create group function var bullets = context.add.group({ classType: Bullet, runChildUpdate: true, maxSize: 40 }); console.log(bullets.getChildren()); /* The log show that have a mount of child in it */ bullets.getChildren().forEach(element => { /* The none of children so the bullets.length = 0, nothing change to the pivot */ element.setPivot(pivot); }); export default class Bullet extends Phaser.Physics.Arcade.Sprite { constructor(scene) { super(scene, 0, 0, 'dan1'); this.pivot = 0; this.power = 1; scene.physics.world.enable(this); this.speed = Phaser.Math.GetSpeed(400, 1); // 400px/1s } preload() { } create() { } update(time, delta) { this.y -= this.speed * delta; this.x -= this.pivot * (this.speed / this.originalY) * delta; if (this.y < -50) { this.destroy(true); }; } fire(x, y) { this.originalY = y - 20; this.setPosition(x, y - 20); this.setActive(true); this.setVisible(true); } setPivot(newPivot) { this.pivot = newPivot; } } Link to comment Share on other sites More sharing options...
GenericDevelopper Posted October 10, 2019 Share Posted October 10, 2019 What your problem ? You didn't ask any question.. Link to comment Share on other sites More sharing options...
Recommended Posts