Dragging actor

DookiDooki Member Posts: 247
edited November -1 in Working with GS (Mac)
Hey all,

Well I'm trying to create a actor I can drag. Looking at Joe's tutorial this is what I have and it's not working. What am I missing? Thanks!

First I created attribute (boolean) "dragging."

Rule: Dragging
All when mouse is down
----Rule
------All when mouse is down
------Attribute: self.dragging is false
----Change attribute
------self.dragging To:true

Rule
All when mouse is down
Attribute: self.dragging is true
----Change attribute
------self.dragging To false.

Nothing happens. I cannot drag or move my actor.

Thanks,
Dooki

Comments

  • firemaplegamesfiremaplegames Member Posts: 3,211
    In the draggable actor:

    Create an attribute (boolean) called dragging.

    Then two Rules, like this:

    Rule
    When Touch is Pressed
    -----Change Attribute: self.dragging To: true
    OTHERWISE
    -----Change Attribute: self.dragging To: false

    Rule
    When self.dragging = true
    -----Constrain Attribute: self.Position.X To: Mouse.Position.X
    -----Constrain Attribute: self.Position.Y To: Mouse.Position.Y
  • JaxterJaxter Member, PRO Posts: 398
    Great, it helped for me too. BUt is possible to rotate actor image to that position where i am dragging actor? (i mean in any angle )
  • DookiDooki Member Posts: 247
    Hey Joe, worked like a champ! Grazie!

    -Dooki
  • peachpellenpeachpellen Member Posts: 977
    Sorry to be noobish here, but will mouse position settings work on an iPhone as touch settings?

    Thanks ^-^;
  • SnippySnippy Member Posts: 19
    sorry to bump this, but the last question concerning the "touch" was not answered and I cannot find this information anywhere else!

    So again, will this work with the touch settings? I cannot reproduce the dragging with touch settings (preview).. but will it work on iDevices?

    Thanks
  • expired_012expired_012 Member Posts: 1,802
    Yea, im pretty sure it will work with touch settings on devices
  • firemaplegamesfiremaplegames Member Posts: 3,211
    Yes. And Touch works on the Mac as well.

    However, Mouse will only act as one Touch on a device - not multitouch.

    Which can be handy if you don't want to allow multitouch in a certain situation.
  • SnippySnippy Member Posts: 19
    Thanks..

    I've ran into the following problem:

    I'd like to be able to touch drag a rectangle, but what happens is that it centers the actor where I have clicked (touched). Is this only happening in the gamesalad preview or on the iphone too? (bad thing I cannot test right now on an iphone)

    What I need is a touchable drag&drop surface that is not jumping to the center!

    Thank you,
    Glenn
  • firemaplegamesfiremaplegames Member Posts: 3,211
    You need to add in a "click offset" to the coordinates. This us simply the distance from the click to the center of the actor. I have this in my throwing/flicking demo on my wall that you can dig through.
  • SnippySnippy Member Posts: 19
    firemaplegames said:
    You need to add in a "click offset" to the coordinates. This us simply the distance from the click to the center of the actor. I have this in my throwing/flicking demo on my wall that you can dig through.

    Thank you, this has helped me :)
  • AppsRacKAppsRacK Member Posts: 346
    sorry to bump an old thread but i just want to say thanks to FMG for mentioning the use of Mouse key. I've been up all night trying to figure out how to control and prevent multi-touch and it finally works. Anyway this may help others on their problem as well. Thanks again.
Sign In or Register to comment.