public override void moved(Vector3 aVector) { //垂直移動した場合の対応策 Vector2 tVector = new Vector2(aVector.x, aVector.z); if (tVector.x == 0 && tVector.y != 0) { tVector = new Vector2((mLastDirection == DirectionImageH.left || mLastDirection == DirectionImageH.stayLeft) ? -0.1f : 0.1f, tVector.y); } switch (DirectionOperator.convertToDirectionH(tVector)) { case DirectionH.left: //左移動 if (mLastDirection != DirectionImageH.left) { mLastDirection = DirectionImageH.left; mAnimator.setRects(mFrameRects[3]); mAnimator.mInterval = 0.2f; } return; case DirectionH.right: //右移動 if (mLastDirection != DirectionImageH.right) { mLastDirection = DirectionImageH.right; mAnimator.setRects(mFrameRects[2]); mAnimator.mInterval = 0.2f; } return; case DirectionH.none: //静止 if (mLastDirection == DirectionImageH.left) { mLastDirection = DirectionImageH.stayLeft; mAnimator.setRects(mFrameRects[1]); mAnimator.mInterval = 0.4f; } else if (mLastDirection == DirectionImageH.right) { mLastDirection = DirectionImageH.stayRight; mAnimator.setRects(mFrameRects[0]); mAnimator.mInterval = 0.4f; } if (mLastDirection == DirectionImageH.stayLeft) { } else if (mLastDirection == DirectionImageH.stayRight) { } return; } }
public override void setDirection(Vector3 aVector) { switch (DirectionOperator.convertToDirectionH(new Vector2(aVector.x, aVector.z))) { case DirectionH.left: mLastDirection = DirectionImageH.stayLeft; mAnimator.setRects(mFrameRects[1]); return; case DirectionH.right: case DirectionH.none: mLastDirection = DirectionImageH.stayRight; mAnimator.setRects(mFrameRects[0]); return; } mLastDirection = DirectionImageH.none; }