how to move a object depending on the increase of the x value?

guillefaceguilleface Member Posts: 1,014
edited May 2012 in Working with GS (Mac)
hey guys, i am making like a volt meter, so i have my line meter at 0, now i have some buttons, depending on the buttons the meter moves left or right, so i try to interpolate the x position but i can't get it to work, for example if the meter is at 10 and i add 40, then the meter should move to 50, i can do this with change attribute but i want my meter to move instead of just changing position.

Answers

  • tatiangtatiang Member, Sous Chef, PRO, Senior Sous-Chef Posts: 11,949
    edited May 2012
    To make a meter, use replicate or constrain attribute with self.size.width and self.position.x.

    Here's a demo using replicate: https://www.dropbox.com/s/apsztaknopx853o/Meter DEMO.zip

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

  • PhoticsPhotics Member Posts: 4,172
    You could use the Move To behavior, setting X to the volt meter attribute and setting Y to self.Position Y
  • guillefaceguilleface Member Posts: 1,014
    thanks i was using like a needle to move like in a old radio but that will work too, thanks
  • tatiangtatiang Member, Sous Chef, PRO, Senior Sous-Chef Posts: 11,949
    thanks i was using like a needle to move like in a old radio but that will work too, thanks
    If you want that, you'll likely need to use sin/cos. There are lots of good demos related to this. If you open GameSalad and click on New and then search for "rotate" you should find some.

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

Sign In or Register to comment.