please help me with a constraining problem.

guillefaceguilleface Member Posts: 1,014
edited May 2012 in Working with GS (Mac)
hi, ok so i have a actor on x=160,y=485, i want to slide this actor up and down when is pressed, having constraining y to mouse position works good but then it moves more than what i want so i try this, when tout constrain self position y to max((567+ self.Size.Width /2)),min((395- self.Size.Width /2)), game.Mouse.Position.Y )) i try height instead of width but no good. or can i interpolate it too?

Answers

  • jn2002dkjn2002dk Member Posts: 102
    Not entirely sure what you're looking for here so apologies if i'm wrong but couldn't you do a move to mouse y instead for fluid controlled motion?
  • GhostShipAppsGhostShipApps Member Posts: 81
    Why are you constrainng your position to your size?? I think that may be the mistake..
  • scitunesscitunes Member, Sous Chef Posts: 4,047
    max(LowerLimit,min(UpperLimit, game.Mouse.Position.Y ))

    So it looks like you would have "(395-(self.size.width/2))" for lower limit and
    "(567+(self.size.width/2))" for the upper limit.

    That should work.
  • guillefaceguilleface Member Posts: 1,014
    still not working but i found another rule . constrain self position y to
    max(min( game.Mouse.Position.Y ,320),0)), now this works good, just would like to know why if i set my playing area from y=320 to y=640 won't work, so i will change the rule to
    max(min( game.Mouse.Position.Y ,640),320)), i think this is a problem i don't understand about the offset position.
  • scitunesscitunes Member, Sous Chef Posts: 4,047
    anytime the camera origin is not at 0,0 you must add the camera offset to the mouse or touch points. So you cannot just use mouse.X or mouse.Y.

    Here's what I would do. Create a real game attribute called game.CameraY
    create an actor called camera. Make this actor immovable and invisible.
    Drag this actor into your scene, unlock it and create the following rule:

    constrain game.CameraY to current.scene.camera.origin.Y

    Now go into the actor that you are trying to constrain and do this:

    max(LowerLimit,min(UpperLimit, game.Mouse.Position.Y+game.CameraY ))


Sign In or Register to comment.