9 years ago by BBreitenbach
So, After some work with the fog of war plugin, I wanted to look for higher performance alternatives.
Assuming I dont care about Line of Sight, the first idea that came to mind was to simply clip out a circle from a fog fillRect covering the whole canvas view. However, I can not get this to work. I did some searching around and testing on tutorial sites, and can't seem to get Impact to do the same. I have to be missing something.
The end goal is to have a transparent circle over the player which is their sight radius, with everything outside the circle getting a fillrect darkend alpha applied to it.
Assuming I dont care about Line of Sight, the first idea that came to mind was to simply clip out a circle from a fog fillRect covering the whole canvas view. However, I can not get this to work. I did some searching around and testing on tutorial sites, and can't seem to get Impact to do the same. I have to be missing something.
The end goal is to have a transparent circle over the player which is their sight radius, with everything outside the circle getting a fillrect darkend alpha applied to it.
ig.system.context.save(); //ig.system.context.beginPath(); //ig.system.context.rect(0, 0, ig.system.width * ig.system.scale, ig.system.height * ig.system.scale); //ig.system.context.fillStyle = "rgba(100, 100, 100, .8)"; //ig.system.context.fill(); //ig.system.context.closePath(); /// create path ig.system.context.beginPath(); ig.system.context.arc((ig.game.player.pos.x + (ig.game.player.size.x / 2) - ig.game.screen.x) * ig.system.scale, (ig.game.player.pos.y + (ig.game.player.size.y / 2) - ig.game.screen.y) * ig.system.scale, 64 * ig.system.scale, 0, 2 * Math.PI); ig.system.context.closePath(); /// set clipping mask based on shape ig.system.context.clip(); /// clear anything inside it //ig.system.context.clearRect(0, 0, ig.system.width * ig.system.scale, ig.system.height * ig.system.scale); this.parent(); /// remove clipping mask ig.system.context.restore()