[SOLVED]FaceDirection diagonals problem?

Started by SpacePaw, Mon 14/06/2010 17:49:22

Previous topic - Next topic

SpacePaw

Hello,
I have no idea why I can't get the character to face diagonal directions with FaceDirection :/ He always ends up looking up/down/left/right
Code: ags

function FaceDirection (this Character*, Directions direction, BlockingStyle block)
{
  if (direction == eUp)
  {
    this.FaceLocation(this.x, this.y-1, block);
  }
  else if (direction == eDown)
  {
    this.FaceLocation(this.x, this.y+1, block);
  }
    else if (direction == eLeft)
  {
    this.FaceLocation(this.x-1, this.y, block);
  }
    else if (direction == eRight)
  {
    this.FaceLocation(this.x+1, this.y, block);
  }
    else if (direction == eUpLeft)
  {
    this.FaceLocation(this.x-1, this.y-1, block);
  }
    else if (direction == eUpRight)
  {
    this.FaceLocation(this.x+1, this.y-1, block);
  }
    else if (direction == eDownLeft)
  {
    this.FaceLocation(this.x-1, this.y+1, block);
  }
    else if (direction == eDownRight)
  {
    this.FaceLocation(this.x+1, this.y+1, block);
  }
}


Here's the function code...I tried increasing 1 to 50 thinking that maybe engine got confused by small values but it didn't help. Suggestions?

Khris

The only reason I can think of: I believe a character can only face directions they can walk in. Is the character on a walkable area?

SpacePaw

Quote from: Khris on Mon 14/06/2010 18:10:12
The only reason I can think of: I believe a character can only face directions they can walk in. Is the character on a walkable area?

Well yes he is...on the very edge of it. I tried all possible face directions and he can face all except the diagonals (even the ones facing the way he came from)

adm244

#3
[deleted]

SpacePaw

Quote from: adm244 on Mon 14/06/2010 18:25:45
SpacePaw, You did't try to go simple path?
Simply having substituted the sprite of the character when it is necessary to turn it :)

Unfortunately the character actually needs to rotate himself from current position to new one. Simple swap won't work here.

Wyz

Make sure every loop in the walk view has at least two frames, just duplicate the first frames if you need to.
I hope that helps you. :)
Life is like an adventure without the pixel hunts.

SpacePaw

Quote from: Wyz on Mon 14/06/2010 19:01:28
Make sure every loop in the walk view has at least two frames, just duplicate the first frames if you need to.
I hope that helps you. :)

Thanks! It works now! I had separate 1 frame view for turning :) it solved it! You rock!

SMF spam blocked by CleanTalk