Report a Bug


  • Impact ForumsLatest from the Impact Forums
  • Impact IRC ChatGet help from others on IRC
Visit Forums

Impact Forums

Using native canvas methods in an entities draw function with transparent rgba fillstyle
Posted December 19, 2014, 11:43 am — by fourstar07
Greetings impacters!

I'm working on a stealth/sneaking style top down view game and trying to show field of vision cones for the enemies. My thought was that I could just use the native canvas methods based on my AI controlled entities position. This all works fine except that when I try to set the ctx.fillStyle to a transparent color, rgba(255,0,0,0.6) or something similar, the result does not paint the background layer under the fill. However, if I simply stroke the ctx path with a decently thick lineWidth and a similar strokeStyle, the lines for the path are rendered transparent with the background tiles showing underneath the stroke. Any thoughts? Some psuedo-ish code to explain what I'm doing:

// In some enemy entity
draw: function() {
 // Retrieve and store canvas ctx
 var ctx = ig.system.context;;
 // The actual implementation is a little more complicated, but irrelevant to my problem
 // This is just to give you an idea of what I'm trying to do
 ctx.lineTo(this.pos.x + this.filedOfVision.radius, this.pos.y);
 ctx.arc(this.pos.x,this.pos.y,this.fieldOfVision.radius, 0, (this.fieldOfVision.sweepAngle * (Math.PI / 180)));
 // This works as I would expect with the background visible under the transparency
 ctx.strokeStyle = 'rgba(255,0,0,0.5)';
 // This draws on the canvas, but there is no background under the field of vision cone
 ctx.fillStyle = 'rgba(255,0,0,0.5)';
Minimap Plugin
Posted December 19, 2014, 9:43 am — by dryas

I've created a new minimap plugin that you can find here:

It will display a minimap with the following features:

- Generate multiple(!) minimaps in different sized (e.g. minimap vs. commander map) on the fly, no "pre-rendered" images needed
- Choose which layers of the map should be displayed on the minimap
- Display entities and their movement by entity type on the map
- Choose if you want the entities displayed as a rectancle or as an image
- Change color, size, offset of entity indicators
- Show viewport of the user on the minimap

It would be nice to get some feedback and suggestions and maybe someone can have a look at the formulars to calculate the coordinates of the "viewport".

Thanks a lot,


Older Posts

Ready to get to the point?

Your Email will remain private and is only used for good. We promise!

Please use only letters, numbers or underscores.