The Daily Click ::. Forums ::. Klik Coding Help ::. Pick up object with mouse
 

Post Reply  Post Oekaki 
 

Posted By Message

Swazey



Registered
  28/07/2003
Points
  53
11th August, 2003 at 20:31:06 -

How do I make it so when I click an object it will pick it up and when I click again it drops it?

 
~Patrick~

*

-----

Wiseman



Registered
  14/10/2002
Points
  18
12th August, 2003 at 02:03:01 -

I did it like this:
1)I made an active object and set its x and y always to the positions of mouse pointer x and y
2)when user cliks left button and my active object is overlapping the oject that I would like to pick then set counter 1
3)when counter is 1, then set the position of the pickable object (0,0) from the picking up object
4)When the user cliks right button, set counter to 0

The last one could be done with left button too, then you need to use another counter..

That was my 1st time to help someone in this forum..I hope I did everything right..

Image Edited by the Author.

 
I33´t lover, baby there´s no other...

Assault Andy

Administrator
I make other people create vaporware

Registered
  29/07/2002
Points
  5686

Game of the Week WinnerVIP Member360 OwnerGOTM JUNE - 2009 - WINNER!GOTM FEB - 2010 - WINNER!	I donated an open source project
12th August, 2003 at 03:22:00 -

Theres a less complex way:

User clicks on active - toggle flag 0

if flag 0 = on, always set active.x,y to mouse.x,y

Easy,

-Andy

 
Creator of Faerie Solitaire:
http://www.create-games.com/download.asp?id=7792
Also creator of ZDay20 and Dungeon Dash.
http://www.Jigxor.com
http://twitter.com/JigxorAndy

Daniel[Crazy_Productions]

Possibly Insane

Registered
  29/12/2002
Points
  2505
12th August, 2003 at 03:48:06 -

yea andy thats easy and it works for multiple objects too

 
Beware of life ...so far noone have survived it.......

Kris

Possibly Insane

Registered
  17/05/2002
Points
  2017
12th August, 2003 at 04:08:48 -

Not quite. you need a flag (a counter) saying if the mouse is occupied or not. otherwise you could pick up more than one object at once

 
"Say you're hanging from a huge cliff at the top of mt. everest and a guy comes along and says he'll save you, and proceeds to throw religious pamphlets at you while simultaniously giving a sermon." - Dustin G

Assault Andy

Administrator
I make other people create vaporware

Registered
  29/07/2002
Points
  5686

Game of the Week WinnerVIP Member360 OwnerGOTM JUNE - 2009 - WINNER!GOTM FEB - 2010 - WINNER!	I donated an open source project
13th August, 2003 at 02:26:18 -

Would it work if you said:
Only one action while event loops?

Or would the object hardly move then?

-Andy

 
Creator of Faerie Solitaire:
http://www.create-games.com/download.asp?id=7792
Also creator of ZDay20 and Dungeon Dash.
http://www.Jigxor.com
http://twitter.com/JigxorAndy
   

Post Reply



 



Advertisement

Worth A Click