Beispiel #1
0
	// ManualUpdate is called once per frame by CharacterBody
	override public void ManualUpdate () {


		//Check if we hit a wall, turn around if we do

		if (body.CheckDirectionCollision (currentDirection)) {
			currentDirection = (currentDirection == CharacterBody.Direction.LEFT) ? CharacterBody.Direction.RIGHT : CharacterBody.Direction.LEFT;
		}

		//Walk in current direction
		if (currentDirection == CharacterBody.Direction.LEFT)
			body.MoveLeft ();
		else if (currentDirection == CharacterBody.Direction.RIGHT)
			body.MoveRight ();
	}
Beispiel #2
0
    // ManualUpdate is called once per frame by CharacterBody
    override public void ManualUpdate()
    {
        //Check if we hit a wall, turn around if we do

        if (body.CheckDirectionCollision(currentDirection))
        {
            currentDirection = (currentDirection == CharacterBody.Direction.LEFT) ? CharacterBody.Direction.RIGHT : CharacterBody.Direction.LEFT;
        }

        //Walk in current direction
        if (currentDirection == CharacterBody.Direction.LEFT)
        {
            body.MoveLeft();
        }
        else if (currentDirection == CharacterBody.Direction.RIGHT)
        {
            body.MoveRight();
        }
    }
Beispiel #3
0
 public bool directionColliding(CharacterBody.Direction dir)
 {
     if (dir == CharacterBody.Direction.LEFT)
     {
         return(LeftIsColliding());
     }
     else if (dir == CharacterBody.Direction.RIGHT)
     {
         return(RightIsColliding());
     }
     else if (dir == CharacterBody.Direction.UP)
     {
         return(TopIsColliding());
     }
     else
     {
         return(BotIsColliding());
     }
 }