flip horizzontally by yourself

I have an actor who moves random
every 2 seconds
interpolated self.position.X to random(100,700)
interpolated self.position.Y to random(100,700)

how can I do the flip horizzontally?
when it goes right?
and when he goes to the left?

all by yourself
without using the mouse

thanks for your attention

Comments

  • KevinCrossKevinCross London, UKMember Posts: 1,894
    Are you changing the image/animation when it moves?

    If so try storing the last random position x and y in an attribute and if the next random x is higher than the last x it's going right (change image/animation accordingly), otherwise it's going left. And do a similar thing for y.
  • wolltywollty Member Posts: 102
    how can I store the last position X and the last posistion Y?
    thanks (and sorry for my bad english, i used google translate)
  • KevinCrossKevinCross London, UKMember Posts: 1,894
    edited August 2013
    Instead of checking it's last position, check the current position against where it's going to.

    Set up two 'real' attributes on the actor called

    Move To X
    Move To Y

    Change Attribute Move To X = random(100, 700)
    Change Attribute Move To Y = random(100, 700)

    Then set up 4 Rules to change the images for 4 directions (vertical included), 2 if you only want to flip horizontal

    If Attribute Move To X < Self.Position.X
    Change Image/animation to Left

    If Attribute Move To X > Self.Position.Y
    Change Image/animation to Right

    Do the same for Y if you want to change image/animation to one that's facing up or down.

    Then

    interpolate self.position.X to Move To X
    interpolate self.position.Y to Move To Y

    You don't need to worry about changing the image if Move To X is the same as Self.Position.X or Move To Y is the same as Self.Position.Y unless you want to use an image where the actor is standing still, tapping his feet etc.
  • wolltywollty Member Posts: 102
    I put a real attribute

    game.lastX

    constrain
    game.lastX to self.positionX

    When
    self.positionX> game.lastX
    change attribute
    self.graphics.Flip orizontally to true

    When
    self.positionX <game.lastX
    change attribute
    self.graphics.Flip orizontally to false
  • wolltywollty Member Posts: 102
    well
    I tried both ways and they both work well

    I think it's better like you said with the real attribute directly into the actor and not in the game

    thank you very much
    :)
  • KevinCrossKevinCross London, UKMember Posts: 1,894
    I don't really understand your example as you're not showing where you're putting the random numbers but if you've got it working how you want then I'm glad to have helped.
Sign In or Register to comment.