using canvas
Posted: Sat Jul 26, 2008 7:06 am
can i make an actor colide only with the line drawn on a canvas to have a physical response?
feral wrote:yes you can
the important thing to remember ,is to erase your canvas first ,otherwise the collision will occur with the entire canvas rather then what is draw on it ( as a canvas is only semi transparent when created until it is erased)
eg: in create actor (canvas)
erase(0, 0, 0, 1);
also your line should be wider then your motion otherwise you may still go through it
eg: if your motion is x=x+4, or xvelocity=4 then the line should be at least 4 pixels wide otherwise you may "skip" over it.
if your line needs to thinner you can use collsionfree to check for the line before you move.
hope that helps
blarghNRawr wrote:im not allowed 2 download ne thing so...
int top;
int base;
top=rand(200);
base=rand(200);
erase(0,0,0,1); // this is NEEDED see notes above
setpen(0, 0, 255, 0, 2);
moveto(top,0);
lineto(0,base);