Staying on a line

TndrstruckTndrstruck Member Posts: 2
edited March 2012 in Working with GS (Mac)
Hi guys,

Im rather new to GS, and still testing out what the engine can do. One of the things im testing out is how to move an actor along a set of lines. Like in this game http://www.tcksoft.co.uk/downloads/remakes/cobex-cruising-on-broadway-extra/

I am able to make it do that, sort of... I cant figure out how to make the actor stay in the middle of the line, and stop when there is no more line or a corner. My actor seem to want to move another 30 pixels before it stops.

Cheers :)

Best Answer

Answers

  • tatiangtatiang Member, Sous Chef, PRO, Senior Sous-Chef Posts: 11,949
    edited March 2012
    To center the actor on a vertical line, constrain self.position.x to line.position.x. To center the actor on a horizontal line, constrain self.position.y to line.position.y.

    Gonna see if I can make a quick demo for you to answer the rest of your question...

    Okay, here's a start: http://dl.dropbox.com/u/19602014/COBEX Clone.zip. You can place the player actor on either line and it will center and constrain to the line's ends. But if you move to the corner, you are colliding with both lines and that's where my rules fail you. Like I said, it's a start!

    New to GameSalad? (FAQs)   |   Tutorials   |   Templates   |   Greenleaf Games   |   Educator & Certified GameSalad User

  • TndrstruckTndrstruck Member Posts: 2
    Thanks Tatiang, that was a help in the right direction. :)
  • TndrstruckTndrstruck Member Posts: 2
    Awsome... just tried the last one, and its more or less spot on. Thanks :)
  • pryceczechpryceczech Member, PRO Posts: 15
    Just wanted to let you know, tatiang, even later, this post really helped me out!
  • tatiangtatiang Member, Sous Chef, PRO, Senior Sous-Chef Posts: 11,949
    @pryceczech great to hear! I just came across this... if you want to notify me (or anyone else), include the @ symbol in front of the person's forum name.

    New to GameSalad? (FAQs)   |   Tutorials   |   Templates   |   Greenleaf Games   |   Educator & Certified GameSalad User

Sign In or Register to comment.