moving objects with mouse

0 favourites
  • 5 posts
From the Asset Store
Hand-painted tiles, objects, animated objects, and background to build a colorful Mayan civilization environment.
  • Hiya,

    Just a couple of quick questions regarding moving objects with the mouse.

    The code i have to do this is as follows :

    Mouse Left Button is down   object   set position to (mouse.x,mouse.y) object pick instance with UID

            object.UID

    Mouse   Cursor is over object

    now firstly when you move the object with the mouse it is very easy to leave it behind if you move the mouse too fast, is there a way to have the object latch onto the mouse cursor so this doesn't happen?

    secondly when you move the object over another object (of the same type) one of the objects disappears.

    and finally if you declare two different objects with similar code to above then when one object is moved over the other object, they latch on.

    Any help would be appreciated, thanks in advance

  • Mouse: on left button clicked on Sprite
          -> Sprite: set selected to True
    Mouse: [invert] left button is down
          -> Sprite: set selected to False
    Sprite: Is selected
          -> Sprite: set position to Mouse.X,Mouse.Y
  • hi thanks for the response, i am kinda new at this stuff, what do you mean by set selected to True?

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • k so this is what i've got :

    set a boolean variable to the object

    Mouse on left button click   object   set variable as true

    pick instance with UID

            object.UID

    Mouse   Cursor is over object

    Mouse Left Button is down   set position(mouse.x,mouse.y)

    pick instance with UID      set variable false

            object.UID

    it works quite well BUT, as soon as i click one of the objects, the instances of the object all disappear...weird?

  • you dont need the uid, if you use the on object clicked, that object will be picked, in the same event you set the boolean "selected" of that object to true

    object boolean selected is true set position to mouse

    Mouse: [invert] left button is down > means when you release the mousebtn

    set selected to false

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)