How to move actors in multiples of 2?

Hey guys,

I'm trying to get my actors to move randomly on the X axis in multiples of 2.

At the moment, they're moving (Move to) along the X axis at random(1,10), which obviously includes 1 and 3,5,7,9. This causes a blur when the actor is at a coordinate with an odd number.

Anybody know how I can move the actor in multiples of 2?

Thanks

Best Answers

Answers

  • shmartybirdshmartybird Member Posts: 17
    Wow, that was easy! Thanks @Socks!!
  • shmartybirdshmartybird Member Posts: 17
    What about if i wanted odd numbers? (Multiples of 1)
  • shmartybirdshmartybird Member Posts: 17
    Thanks @gyroscope.
    Ah my images are clear when moving but still become blurry when the actor stops.

    I thought that moving the actor to an even/odd number position would stop the blurryness. Does anyone else have issues with coordinates and image clarity?
  • SocksSocks London, UK.Member Posts: 12,822
    What about if i wanted odd numbers? (Multiples of 1)
    Everything is a multiple of 1 (every whole number).
  • SocksSocks London, UK.Member Posts: 12,822
    edited November 2013
    I thought that moving the actor to an even/odd number position would stop the blurryness.
    If you place an actor on a sub-pixel value (like 500.5 or 231.7) it will make the image blurry, but placing an actor on an odd or even numbered pixel value has no effect on image quality (ie: placing an actor at X=500 or x+501 won't make it blurry).

    Annoyingly GameSalad places actors on sub-pixel values when you drag them into a scene, so to avoid blurriness all the actors you place in your scene (which sometimes can be hundreds) need to have their positions corrected/rounded up/down once they're placed in the scene.
  • shmartybirdshmartybird Member Posts: 17
    Hmmm, is it because the position of the actor might not be a round number then? (i.e Position X = 234.1242777) Would that cause a blur?
  • SocksSocks London, UK.Member Posts: 12,822
    Hmmm, is it because the position of the actor might not be a round number then? (i.e Position X = 234.1242777) Would that cause a blur?
    See above (I think I was editing my post as you were posting).
  • shmartybirdshmartybird Member Posts: 17
    Excellent. So if my actor was moving and stopping randomly across the screen, i would have to somehow automatically round up the X position it stopped at (to make sure it didn't stop at a sub-pixel value)?

    Would I use the floor function for this?
  • SocksSocks London, UK.Member Posts: 12,822
    Excellent. So if my actor was moving and stopping randomly across the screen, i would have to somehow automatically round up the X position it stopped at (to make sure it didn't stop at a sub-pixel value)?

    Would I use the floor function for this?
    In theory because you are using 'Move to' you shouldn't be landing on a sub-pixel value (unless you are telling it to do so).
  • shmartybirdshmartybird Member Posts: 17
    edited November 2013
    Okay so I needed actors to move to the left of the screen (Move to pixel 1), and then stop and start moving again at after a few random seconds. Kind of like people walking down a street, stopping for a few seconds, and then walking again.

    My code is:
    --------------------
    Every random(1,5) seconds
    Move to: Position random(1,10) Relative to scene
    Speed random(20,50)

    Timer: After random(1,5) seconds
    For random(2,8) seconds
    Change attribute self.XtargetPos to self.Position.X
    Constrain attribute self.Position.X to self.XtargetPos
    -------------------

    It's hard to because I have no idea what their X coordinates will be each time they stop moving. So they might be stopping at a random sub-pixel coordinate every time.

    Sorry to keep going on :)
  • SocksSocks London, UK.Member Posts: 12,822
    edited November 2013
    It's hard to because I have no idea what their X coordinates will be each time they stop moving.
    Just stick a 'Display text' behaviour in the actor and get it to display whatever you want (presumably in this case you'd want it to display self.position.x).
  • shmartybirdshmartybird Member Posts: 17
    HOLY SMOKES I FIGURED IT OUT!!
    It's not the actor that's the problem. It's where the camera happens to be in relation to the actors/background!!
    My camera is moving along the X axis as the main character moves, but the main character is never blurry.

    So basically the screen is moving at sub-pixel values.
    Wow. You figure one thing out and a whole other set of problems arise!
    Thanks guys...
Sign In or Register to comment.