本文整理汇总了C#中Box.SetXSpeed方法的典型用法代码示例。如果您正苦于以下问题:C# Box.SetXSpeed方法的具体用法?C# Box.SetXSpeed怎么用?C# Box.SetXSpeed使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Box
的用法示例。
在下文中一共展示了Box.SetXSpeed方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Start
void Start()
{
world = new World();
var box = new Box(0, 5, 1, 1, "test");
box.SetXSpeed(2);
box.SetEnterOtherBoxCallback ((b) => {
Debug.Log("Enter "+b.name);
});
world.AddBox (box);
// box.lockSpeedX = true;
for (int i = 0; i<10; i++) {
world.AddBox(new Box(0+i, 0, 1, 1, "hitTest"+i), true);
}
// world.AddBox(box);
// world.AddBox(new Box(0, -2, 50, 3, "2"), true);
// testBox = new Box(0, 0, 2, 2, "3");
// world.testBox = testBox;
// world.AddBox(new Box(5, 0, 3, 3, "4"), true);
// world.AddBox(new Box(35, -15, 30, 1f, "5"), true);
// world.AddBox(new Box(40, -9, 1, 13, "6"), true);
}
示例2: MoveBox
public void MoveBox(Box box, Vector2 speed)
{
Vector2 xSpeed = new Vector2(speed.x, 0);
Vector2 ySpeed = new Vector2(0, speed.y);
bool xInBox = false;
bool yInBox = false;
List<Box> enterBoxList = new List<Box>();
foreach (var b in triggerList)
{
Box.BoxCheckResult tmXInBoxCheck ;
Box.BoxCheckResult tmYInBoxCheck ;
tmXInBoxCheck = (box.CheckMoveBoxX(b, speed));
tmYInBoxCheck = (box.CheckMoveBoxY(b, speed));
if (tmXInBoxCheck != Box.BoxCheckResult.OutBox || tmYInBoxCheck != Box.BoxCheckResult.OutBox)
{
enterBoxList.Add(b);
}
if (tmXInBoxCheck == Box.BoxCheckResult.InBox || tmYInBoxCheck == Box.BoxCheckResult.InBox)
{
box.MoveToPivotPos(b, box.pos + speed, speed);
}
if (tmXInBoxCheck== Box.BoxCheckResult.InBox) xInBox = true;
if (tmYInBoxCheck== Box.BoxCheckResult.InBox) yInBox = true;
}
box.CheckEnterBox(enterBoxList);
if (xInBox || yInBox)
{
if (xInBox)
{
box.SetXSpeed(0);
}
else
{
box.SetPosXAdd(speed.x);
}
if (yInBox)
{
box.SetYSpeed(0);
}
else
{
box.SetPosYAdd(speed.y);
}
return;
}
box.pos += speed;
}