The Daily Click ::. Forums ::. Klik Coding Help ::. Making an object follow the mouse?
 

Post Reply  Post Oekaki 
 

Posted By Message

JetpackLover



Registered
  01/03/2007
Points
  212
10th January, 2009 at 04:25:05 -

I am using this code currently

+Mouse is overlapping object
+left click of mouse is being held
-set x position of object to xmouse.

Thats all well and good but if you move too fast the mouse detaches from the object.

So I decided to use flags so that it would lock on and that did work but I didn't know what code to use that would make it detach. Anyone know what I can do?

 
http://www.invincibletime.com/

Devlog for HD MMF Game Omulus. Check it out because it's gonna be awesome. http://omulus.tumblr.com/

Follow me on the twitters https://twitter.com/JetpackLover


Deleted User
10th January, 2009 at 04:31:32 -

Create an active and set it to XY of the mouse, then have the object you want to follow it set to bouncing ball and always look at the object set on the mouse. Then of course set to events when the object is touching the mouse object and the object is not touching the mouse object, and then put the start and stop movement to the respective event.

This is the simple way, there is a more complex way using mathematics that would use less actives, and you can achive a greater result using extentions. The other members of the community that know there math might be able to tell you the equations and stuff, my brain isn't working well right now though. Sorry.

EDIT: I'm a little confused on what you want to accomplish, do you want the object to follow the mouse when it is clicked? Do you want to drag the object? Or what I just said and just have it follow the mouse?

Edited by an Administrator

 

OMC

What a goofball

Registered
  21/05/2007
Points
  3309

KlikCast Musician! Guy with a HatSomewhat CrazyARGH SignLikes TDCHas Donated, Thank You!Retired Admin
10th January, 2009 at 04:39:16 -

(Negate) Repeat while left mouse button is being held
+ Object Flag is on
>Set flag off.

I think that's what you wanted...

If it's still detaching, you may need to use fastloops.

Edited by OMC

 

  		
  		

JetpackLover



Registered
  01/03/2007
Points
  212
10th January, 2009 at 05:10:41 -

oh wow am I stupid, thanks old man...I should've waited longer until it came to me.

 
http://www.invincibletime.com/

Devlog for HD MMF Game Omulus. Check it out because it's gonna be awesome. http://omulus.tumblr.com/

Follow me on the twitters https://twitter.com/JetpackLover


Knockturnal

Nothing to see here turn back

Registered
  11/04/2008
Points
  352

VIP Member
10th January, 2009 at 11:05:21 -

I can fix it when i get on my compo...

Currently on iPhone lol

 
Professional vaporware developer

Cecilectomy

noPE

Registered
  19/03/2005
Points
  305

Has Donated, Thank You!VIP MemberWeekly Picture Me This Winner!Cardboard BoxGhostbuster!Pokemon Ball!ComputerBox RedSanta HatSnowman
I am an April Fool
10th January, 2009 at 11:14:30 -

its already fixed

 
n/a

Knockturnal

Nothing to see here turn back

Registered
  11/04/2008
Points
  352

VIP Member
10th January, 2009 at 12:57:45 -

Lmao I thought he meant drag and drop... Maybe then again- he did but i'm to stupid to understand it

 
Professional vaporware developer

OMC

What a goofball

Registered
  21/05/2007
Points
  3309

KlikCast Musician! Guy with a HatSomewhat CrazyARGH SignLikes TDCHas Donated, Thank You!Retired Admin
10th January, 2009 at 16:13:21 -


Originally Posted by DudeHuge
oh wow am I stupid, thanks old man...I should've waited longer until it came to me.



Naw, everyone has brain farts.

 

  		
  		
   

Post Reply



 



Advertisement

Worth A Click