polansk1 Posted May 15, 2018 Share Posted May 15, 2018 Hi again! i will make a mask covering all canvas but my player, making a circle around him. And i will that circle follow the player all time. I found that code but i think its not working because it's Phaser2. How can i do that? mask = game.add.graphics(0, 0); mask.beginFill(0xffffff); mask.drawCircle(100, 100, 100); fondo.mask = mask; fondo.mask = mask; Link to comment Share on other sites More sharing options...
squilibob Posted May 16, 2018 Share Posted May 16, 2018 you should set the mask like so: fondo.setMask(new Phaser.Display.Masks.BitmapMask(this, mask)) Link to comment Share on other sites More sharing options...
polansk1 Posted May 16, 2018 Author Share Posted May 16, 2018 dont know how to define mask :S I have a background (fondo) and a sprite (player). How i set the mask covering all background except player? I'm newbie in phaser sorry and it's difficult to learn for me because i dont have too many documentation for phaser3... Link to comment Share on other sites More sharing options...
squilibob Posted May 17, 2018 Share Posted May 17, 2018 let mask = this.make.graphics({ fillStyle: { color: 0x000000 }, add: false}) .fillCircleShape(new Phaser.Geom.Circle( 100, 100, 100 ) Link to comment Share on other sites More sharing options...
polansk1 Posted May 18, 2018 Author Share Posted May 18, 2018 Ty man! i found it at end : preload: this.load.image('mask', 'img/mask1.png'); create: spotlight = this.make.sprite({ x: 400, y: 300, key: 'mask', add: false }); background.mask = new Phaser.Display.Masks.BitmapMask(this, spotlight); update: spotlight.x = player.x; spotlight.y = player.y; The problem with that is i have to apply the mask to all layers, if i only apply to one layer i see the other objects on top of the mask. If anyone know another way to apply the mask to all canvas at same time i will appreciate it but at the moment that it's ok im happy! Link to comment Share on other sites More sharing options...
squilibob Posted May 22, 2018 Share Posted May 22, 2018 You can add all your layers to a container and set the Mask on the container Link to comment Share on other sites More sharing options...
Recommended Posts