我是AS3的新手,非常喜欢碰撞检测方面的帮助。我目前正在制作一款与机器人独角兽攻击相似的游戏(连续,'无限',等级); sidecrolling running platformer。我找到了0个连续/循环运行风格平台游戏的教程,所以我来到这里!我有一个静止的播放器,平台编写脚本以移动到屏幕左侧以进行滚动/运行效果。我在舞台上有三个平台实例,但是播放器只会对一个的做出反应。正在从所有平台检测到碰撞。
下面的代码用于在我的游戏循环函数中执行的碰撞。非常感谢帮助! :D谢谢。
for (var i = 0; i < numChildren; i++)
{
if (getChildAt(i) is Platform)
{
var platformHolder = getChildAt(i) as Platform
if (platformHolder.hitTestPoint(player.x + leftBumpPoint.x, player.y + leftBumpPoint.y, true))
{
trace("left hit")
leftBumping = true;
}
else
{
leftBumping = false
}
if(platformHolder.hitTestPoint(player.x + rightBumpPoint.x, player.y + rightBumpPoint.y, true))
{
trace("right hit");
rightBumping = true;
}
else
{
rightBumping = false;
}
if(platformHolder.hitTestPoint(player.x + upBumpPoint.x, player.y + upBumpPoint.y, true))
{
trace("Up hit");
upBumping = true;
}
else
{
upBumping = false;
}
if(platformHolder.hitTestPoint(player.x + downBumpPoint.x, player.y + downBumpPoint.y, true))
{
trace("down hit");
downBumping = true;
}
else
{
downBumping = false;
}
}
}
if(leftBumping)
{
if(xSpeed < 0)
{
xSpeed *= -0.5;
}
}
if(rightBumping)
{
if(xSpeed > 0)
{
xSpeed *= -0.5;
}
}
if(upBumping)
{
if(ySpeed < 0)
{
ySpeed *= -0.5;
}
}
if(downBumping)
{
if(ySpeed > 0)
{
ySpeed *= -0.5;
}
}
else
{
//if not touching the floor
ySpeed += gravityConstant;
}
答案 0 :(得分:-1)
If(platformholder[i].hitTestObject(player))
添加你制作循环的原因