Page 1 of 1

Assign Hit Regions in a loop

Posted: 12 Apr 2014 19:33
by shanekoss
HI - Using this script to create 8 squares and all works well except assigning a hit region for each one - am i missing a step?

thanks!

decl i,offy,offset;
canvas_clear(c);
for(i=0;i<8;i++){
if(i<4){
offy=0;
offset=0;
}
else{
offy=150;
offset=600;
}
canvas_setStrokeStyle(c, 0.5);
canvas_setLineWidth(c, 10);
canvas_setFillStyle(c, 1);
canvas_fillRect(c, i*150-offset, offy, 150, 150);
canvas_addHitRegion(c,0,i);
canvas_setStrokeStyle(c, border);
canvas_setLineWidth(c, 10);
canvas_strokeRect(c, i*150-offset,offy , 150, 150);
canvas_setTextAlign(c, 1);
canvas_setFontSize(c,18 );
canvas_setTextBaseline(c, 1);
canvas_setFillStyle(c, {0,0,0});
canvas_fillText(c, 'Drummer'+(i+1), 75+i*150-offset, offy+75, 140);
}

Re: Assign Hit Regions in a loop

Posted: 14 Apr 2014 14:30
by Macciza
Hi
Try canvas_rect instead of canvas_fillRect - fillRect is a shortcut method I think and does not give you a Path it seems . .
And add a canvas_beginPath in there somewhere to make sure you get separate paths in the end . . .
HTH
MM