Drag and Drop on Wiki does not seem to work

DaveyJJDaveyJJ Member Posts: 12
edited November -1 in Working with GS (Mac)
I set up a new project. 1024x768 iPad size. GS 0.8.7. I have two (square) actors set up with the Wiki script for drag and drop correctly set up. Put them in a scene and preview, and they will not not drag and move when the mouse is over them and clicked down and moved. What could be going wrong? This is incredibly frustrating, to say the least.

Comments

  • gyroscopegyroscope I am here.Member, Sous Chef, PRO Posts: 6,598
    Hi DaveyJJ: haven't got to dealing with drag yet, so did a quick test. The following might not be exactly what you're after, or there's a better way, I don't know, but here we are anyway:

    make sure you've put a number into Drag and Angular Drag (you might just only need Angular Drag, I don't know). For the test I gave them both 300 each. In the Actor's Rule, put When Actor receives event - touch is pressed, then Move attribute.

    I guess you're after swipe as a touch; unfortunately I don't know how to do this yet, to be able to let you know.

    ;-)

    ---------------------------------------------------------------
    Spiral Gyro Games

    ""You are in a maze of twisty passages, all alike." - Zork        temp domain http://spidergriffin.wix.com/alphaghostapps

  • RHRH Member Posts: 1,079
    You asked this question at exactly the right time!

    Yesterday I made this to help JCFord out and it might have some relevance to what you are doing. I haven't taken a look at the Drag and Drop in the wiki but I would assume the result you want is something like this:

    http://gamesalad.com/game/play/62234

    Hope it helps.
  • ckck Member Posts: 224
    This may not be your issue, but I spent three hours trying to sort this problem yesterday. I finally realised I had used Change Attribute, rather than Constrain Atrtribute.

    Easy to do, but --- face/palm.
  • DaveyJJDaveyJJ Member Posts: 12
    @ck ... I am definitely using change attribute to make the self.DragAndDrop = true, and constrain attribute with self.Position in the bottom rule, per the Wiki. I had double checked that because that's the sort of thing I frequently mess up myself.

    @gyroscope. I'm simply trying to do the drag and drop behaviour shown in the Wiki, to move an actor around with a click, drag, and drop. Not move to the mouse position. http://gamesalad.com/wiki/how_tos:gsc_drag_and_drop_movement

    @RH. I will look at that later this evening. I have followed the Wiki to the letter though. I also do not need physics etc. This is simply to click to drag and move a playing piece from location A to location B, where it stays after I release the mouse/touch.
  • gyroscopegyroscope I am here.Member, Sous Chef, PRO Posts: 6,598
    DaveyJJ said:

    @gyroscope. I'm simply trying to do the drag and drop behaviour shown in the Wiki, to move an actor around with a click, drag, and drop. Not move to the mouse position. http://gamesalad.com/wiki/how_tos:gsc_drag_and_drop_movement

    Tut, I really must start reading posts properly, really; sorry about that...I'll check out the link, thanks.

    PS RH: neat demo; Think I'll have a go at making the outside of the container collidable, out of interest, so it stops the dragged actor...

    PPS I've just done the Drag & Drop Wiki and it's working OK. I'll publish it if you like, so you can compare the game files. i'll let you know the link as soon as I know.

    ---------------------------------------------------------------
    Spiral Gyro Games

    Added: Here you go: http://gamesalad.com/game/play/62471

    ""You are in a maze of twisty passages, all alike." - Zork        temp domain http://spidergriffin.wix.com/alphaghostapps

  • DaveyJJDaveyJJ Member Posts: 12
    Except for the iPad size, I can see nothing different between your file and mine, gyroscope. I noticed you had the code for drag and drop on the scene Actor and not it's game parent, so I tired that too, but no change. I also noticed you named the attribute DragAnd Drop with space. Mine is all one word, but I can't see that mattering. I will try the same code with a smaller project size and see if I can get it to work. Thanks for your effort.

    Here's my test project I created this morning. Not working.

    http://gamesalad.com/game/play/62542
  • firemaplegamesfiremaplegames Member Posts: 3,211
    In the Actor you want to be dragged:
    (and just to be clear, this is the actor in the library - the prototype.)

    Create a boolean Attribute, called something like 'dragging' (without the quotes).

    Create two Rules, like this:

    Rule
    When all conditions are valid:
    Touch is pressed
    -----Change Attribute: self.dragging To: true
    otherwise
    -----Change Attribute: self.dragging To: false

    Rule
    When all conditions are valid:
    self.dragging = true
    -----Constrain Attribute: self.Position.X To: Mouse.Position.X
    -----Constrain Attribute: self.Position.Y To: Mouse.Position.Y

    (Mouse Position is located in the Devices section.
    Also, Mouse gets translated to Touch on a device)

    That will do the trick!

    Hope this helps!
    Joe

    EDIT:

    So I looked at your project.
    First, you should put code in the actor in the Library - Not in the Scene. I would delete that Actor in the Scene. Put all of your code into the one in the Library, then drag it out into the Scene again.

    The reason why your code is not working is because in the second Rule, you are using Change Attributes instead of Constrain Attributes. If you change them to Constrain Attribute behaviors, it will work. However, I still recommend putting the code in the prototype (the one in the Library) only. That padlock you clicked on in the Actor is there for a reason.
Sign In or Register to comment.