Enable drag and drop and Bound to viewport

0 favourites
  • 9 posts
From the Asset Store
Use inertion of your movements to throw, rotate your objects and etc. Objects can interact with others while dragging.g
  • Hello,

    I two problems with drag and drop:

    1. If i not initially enable drag and drop i cant enable it later in the game with set drag and drop enabled

    2. I dont understand how to constrain drag and drop to the screen? I see there is for the layout but my layout is bigger than my viewport.

    Hoping someone can help me out=)?

    /Isak

  • I prefer making a separate (invisible) draggable sprite.

    Say, you want to drag a small ball. Add another sprite DragBox, you can make it bigger than the ball, add Drag&Drop behavior to it. Add these events:

    DragBox is dragging -> Ball set position to (clamp(DragBox.x, ViewportLeft,ViewportRight), clamp(DragBox.y, ViewportTop,ViewportBottom))

    DragBox on Drag end -> DragBox set position to (Ball.X, Ball.Y)

    You can change clamp() parameters to limit dragging to some small area of the screen.

  • Hello Dop2000,

    Thanks for reply but cant get it to work, to me it feels like Construct 3 is buggy? Things that should work dosent or perhaps i am doing something wrong? I've tried what you told me but it did not seem to work?

    I did not found drag on end so i used on drop is this the same?

    I tried to insert an image but dont know how to do it? How do i add it into the post after i have uploaded it?

    /Isak

  • Yes, I meant "On drop".

    To add an image into post, use img tag, for example:

    [img=1234]

    It would be much easier to help if you could share your code or your project file.

  • Aah okey, heres is the game running and also the events. Shuold not the ship follow the cube?

    /Isak

  • I don't know why it doesn't work for you.

    Try this demo:

    dropbox.com/s/fytd9r6f0x4l5jo/DragWithPadding.c3p

  • Hello again,

    Okey i finally found out the problem, i used several event sheet but i didnt used the main there i inlcuded all event sheets=)

    /Isak

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • An easier method is to use my free addon named : Bounded Drag & Drop.

    Link : https://www.construct.net/ph/make-games/addons/91/bounded-drag-drop

    Then set the bounding positions to the View-port Edges.

    There is a good documentation for it with examples on the link for all the features.

  • Hello chadorireborn,

    I will check out your addon now when i know what i did to cause my error=)

    Thanks all!

    /Isak

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