Movement - change image

michael7@post1.dansknet.dkmichael7@post1.dansknet.dk Member Posts: 6
edited January 2013 in Working with GS (Mac)
Hi guys. im having a slight problem (this is my first game, so no wonder)

im making this cargame, with an actor (a car) moving by dragging around using touch in the scene.

i did that by following this:
http://www.youtube.com/watch?feature=player_embedded&v=0_3yp8AP2iE
(when touch is pressed - constrain self.position.x to game.touches.touch1.x and
when touch is pressed - constrain self.position.y to game.touches.touch1.y)

then i wanted my image to change when dragging left and right (skid marks for the car )
so i did this:

Rule: if self.motion.linearvelocity.x is greater then 0, change image to [new image].
Rule: if self.motion.linearvelocity.y is less then 0, change image to [new image].

but that doesnt work. is it because there is no velocity upon dragging my actor around with the touch?
if so how do i make this work? please help

thank you guys

Comments

  • RThurmanRThurman Member, Sous Chef, PRO Posts: 2,881
    edited January 2013
    No need to make two two posts about the same thing. Just bump the old one after a day or so. (I deleted the duplicate discussion. I also moved this thread from "Coding Programming\Logic Services" to "Working with GameSalad".)

    You are correct that constraining X,Y won't give you linear velocity. To get linear velocity, you would need to do a different kind of mouse drag (in which you actually constrain linear velocity instead). It goes something like this:

    Rule: When touch is pressed:
    -- Constrain Attribute: self.motion.Linear Velocity.X To: 50*(( game.Touches.Touch 1.X - self.Position.X )*.5)
    -- Constrain Attribute: self.Motion.Linear Velocity.Y To: 50*(( game.Touches.Touch 1.Y - self.Position.Y )*.5)
  • gyroscopegyroscope I am here.Member, Sous Chef, PRO Posts: 6,598
    edited January 2013

    Hi @michael7@post1.dansknet.dk Firstly to say, it is actually against the rules to include punctuation (except the dash underscore: _ ) in your Forum name; worse still, you've included the @ symbol, something that other members add to your name when referring/writing to you.... (you see how it hasn't worked because of the punctuation & @ you've included) best to change it to something simpler, without punctuation...

    You can put your email address in your profile, if you wanted...

    OK, your problem: of the top of my head, try this, should work:

    Rule: When touch is pressed
    Change image to [new image]
    constrain attribute self.position.x to game.touches.touch1.x
    constrain attribute self.position.y to game.touches.touch1.y

    Rule: When touch is released
    Change image to [original image]


  • thanks for the tips ill try them out! :)

    "No need to make two two posts about the same thing"

    - that was not my intention. i just realized i wrote in the wrong categori, and dont know how this forum works quite yet, so i didnt delete the old one.

    "Firstly to say, it is actually against the rules to include punctuation (except the dash underscore: _ ) in your Forum name"

    - actually this is a name given to me automaticly upon sign up. i will change this to a personal user asap :)
  • gyroscopegyroscope I am here.Member, Sous Chef, PRO Posts: 6,598


    - actually this is a name given to me automaticly upon sign up. i will change this to a personal user asap :)
    Oh, I didn't realise that happens nowadays... apologies, Michael. (It's been a long time since I signed up) :-) Yes, a personal user name will be better rather than a whole email address...
Sign In or Register to comment.