【发布时间】:2015-01-30 03:16:41
【问题描述】:
所以我正在制作一个平台游戏风格的游戏,并尝试用一条线进行命中测试,如果这有任何意义的话。现在我有一个四处移动的物体,每当你向右移动时,如果右下角或右上角撞到你停止移动的世界。与左设置相同的东西。但是,如果“世界”电影剪辑太小并且没有达到您可以直接通过的任何点,则此方法有效。所以我需要在这些点之间画一条实线并用它进行 hitTest 吗?
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);
}
我尝试添加的行代码
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;现在肉眼看不见,但计算机可以检测到对它的“命中”?您的问题不清楚..您不知道如何制作这条线或什么? -
@VC.One 已经尝试通过添加此线条形状,也许我做的不对?见编辑
标签: actionscript-3 flash actionscript adobe flash-cs6