Hello,
As mentioned in the topic I want mask to move along with the sprite. I do know that the Masks are positioned in global space and are not relative to the Game Object to which they are applied
but is it possible to do the above?
Below is the code :
let sprite = this.physics.add.sprite(0, 0, 'spritesheetName', 'kay');
var pos = { x1: sprite.getLeftCenter().x, y1: sprite.getLeftCenter().y, x2: sprite.getCenter().x, y2: sprite.getCenter().y };
var size = { w: sprite.displayWidth, h: sprite.displayHeight };
const shape = this.make.graphics();
shape.lineStyle(size.w, 0x000000, 1);
shape.lineBetween(pos.x1, pos.y1, pos.x2, pos.y2);
const mask = shape.createGeometryMask();
sprite.setMask(mask);
sprite.setVelocity(-50);
Thank you.