losos
1
this.load.spritesheet('OB', 'assets/ob.png', { frameWidth: 25, frameHeight: 25 });
this.ob = this.physics.add.group();
this.ob.create(600, 400, 'OB');
this.anims.create({
key: 'sample',
frames: this.anims.generateFrameNumbers('OB', { start: 0, end: 1 }),
frameRate: 10,
repeat: -1
});
i try this.ob.anim.play(‘sample’,true); but not work, how to animate this object?
Any reason you are creating a group rather than a sprite for this.ob
?
You can use the play
method if ob
is a game object:
this.ob.play('sample', true);
If you do want to keep this.ob
as a group, you can use the playAnimation
method:
this.ob.playAnimation('sample')
1 Like
losos
3
This solve my problem, thanks.
I use group because other function in code generate more Objects for this group.