so I'm making a platformer style game and trying to make a hit test with a line if that makes any sense. Right now I have a object that moves around and whenever you're moving right, if the lower right or upper right side hit the world you stop moving. same thing set up with left. This works however if the "world" movieclip is too small and doesn't hit any of the points you can go right through it. So I need to make a solid line between the points and have a hitTest with that?
else if (keyIsDown(Keyboard.RIGHT))
{
//dude.gotoAndStop("right");
//obj.scaleX = 1;
for (i = 0; i<speedX; i++)
{
obj.x++;
dude.ball.rotation++;
if (status == "ground")
{
dude.height+= 0.05;
dude.width += 0.05;
}
if (world.hitTestPoint(obj.x + obj.width/8 - obj.width/2, obj.y - obj.height/4,true) || world.hitTestPoint(obj.x + obj.width/2,obj.y - obj.height + obj.height/4,true))
//this is what dictates the points that hit, trying to make it test a hit with a solid line between the 2 points.
//if (world.hitTestObject(dude.hitD))
{
dude.ball.rotation--;
obj.x--;
break;
}
}
}
dude.gotoAndStop(1);
}
line code I tried adding
else if (keyIsDown(Keyboard.RIGHT))
{
//dude.gotoAndStop("right");
//obj.scaleX = 1;
for (i = 0; i<speedX; i++)
{
obj.x++;
dude.ball.rotation++;
myShape.graphics.moveTo(obj.x + obj.width/8 - obj.width/2,obj.y - obj.height/4);
myShape.graphics.lineTo(obj.x + obj.width/2, obj.y - obj.height + obj.height/4);
// The number in obj.y-4 affects the climbing ability
if (status == "ground")
{
//dude.height+= 0.05;
//dude.width += 0.05;
}
if (obj.hitTestObject(myShape))
{
dude.ball.rotation--;
obj.x--;
break;
}
}
}
dude.gotoAndStop(1);
}
solid_line.alpha = 0;
now its invisible to the eye but the computer can detect a "hit" against it? Your question is not clear.. you dont know how to make the line or what? – VC.One