Impact

This forum is read only and just serves as an archive. If you have any questions, please post them on github.com/phoboslab/impact

1 decade ago by Aliasse

Hi, Impact is a beautiful framework but I'd like to do a pie with different segment and then rotate it, like a wheel.
My first question is, is that even possible to create different segment (triangles) and create a pie like this ?
My aim is to create a wheel rotating and that stop on a particular segment. How can I detect on which segment the wheel stops ?
Thanks for your help :)

1 decade ago by vincentpiel

i did something similar a few times ago : draw a slice to report the progress with the level. I give you here the raw code, you might use it within the 'draw' method of an entity, for instance. To animate it, just have an angle variable updated in 'update' method.

// draw current status within level
var ctx=ig.system.context;
var radius=12, x=130,y=110;
ctx.save();
ctx.scale(ig.system.scale, ig.system.scale);
// draw a full circle
ctx.fillStyle='yellow';
ctx.strokeStyle='black';
ctx.beginPath();
ctx.moveTo(x+radius,y);
ctx.arc(x,y, radius, 0, 6.3);//1.0 ) ;
ctx.fill();
ctx.stroke();
// draw a red slice within the circle, starting from the top of the circle
// this.statusWithinLevel is a figure between 0.0 and 1.0
ctx.fillStyle='red';
ctx.beginPath();
ctx.moveTo(x,y);
ctx.arc(x,y, radius, -1.5708, -1.5708+6.28 * this.statusWithinLevel);
ctx.fill();
ctx.restore();
Page 1 of 1
« first « previous next › last »