Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Author
Message
Rims Flames
11
Years of Service
User Offline
Joined: 5th Apr 2014
Location:
Posted: 21st Aug 2014 12:07
Hello,

I want to drag an object when i am dragging and arrow. How can i possibly do this?



Thank You very much!

Rims Flames
TheComet
17
Years of Service
User Offline
Joined: 18th Oct 2007
Location: I`m under ur bridge eating ur goatz.
Posted: 21st Aug 2014 17:52 Edited at: 21st Aug 2014 18:10
This might be useful to you:
http://forum.thegamecreators.com/?m=forum_view&t=211243&b=6

Here's an example showing how to drag something using the code from the link above:



The idea is simple: Every object that can be picked up stores a flag indicating whether it's being dragged or not. When the mouse is clicked, every object that's within range of the mouse will set its flag to "enabled". While the mouse is being held down, position all objects with an enabled flag at the coordinates of the mouse. When the mouse button is released, reset all flags to "disabled".

This method has one drawback: You can drag multiple objects at the same time. If you don't want this behaviour, then instead of giving each object an individual flag, create a global flag that stores the active object being dragged. This way only one object can be picked up at a time.

Login to post a reply

Server time is: 2025-05-14 23:03:03
Your offset time is: 2025-05-14 23:03:03