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.

Dark GDK / Placing object on cursor position

Author
Message
Bjorn
14
Years of Service
User Offline
Joined: 20th Mar 2010
Location:
Posted: 3rd Jun 2010 08:54
I'm trying to move around an object whit the mouse,
Its working now, but the object is more left-down than the mouse,



Someone know how to place it precisely on the cursor?
haliop
User Banned
Posted: 3rd Jun 2010 14:57 Edited at: 3rd Jun 2010 14:58
ahha!
here is what you need


wait now i see that your Y 2D Axes is on the Z 3D Axes , why is that?
top view?

btw this code may also have some glithces about it positiones according to the mouse , what are you aiming to do? maybe i can help if i'll know a bit more.
Hassan
15
Years of Service
User Offline
Joined: 4th May 2009
Location: <script> alert(1); </script>
Posted: 3rd Jun 2010 15:22 Edited at: 3rd Jun 2010 15:26
i think it depends on the camera position, this code will not work unless the camera's position is at
(x,y,z)
( ScreenWidth/2, distance,-ScreenHeight/2 )
and pointing to
( ScreenWidth/2, 0, -ScreenHeight/2 )

not really sure how to get "distance" variable at the moment, but you can try and see if anything fits

EDIT: i've just seen haliop's post, it might also depend on the object's pivot, if the pivot is in the middle of the object this code will work, or else, you'll have to find it and position it according to the pivot's position, something like what haliop wrote ( haliop's code would work if the pivot is in the corner of the object (maybe GDK's object's pivots are always at the corner? not sure) )

haliop
User Banned
Posted: 3rd Jun 2010 15:40
yeah its the default same for sprites.
Top Right corner i think, thats why he sees it Down Left.

Object Pivot will even be better cause then it will use less code each loop time.
Bjorn
14
Years of Service
User Offline
Joined: 20th Mar 2010
Location:
Posted: 3rd Jun 2010 18:03
I found my problem...
Because my camera looks whit an angle the position isn't correct,
I added some so its better now, but I also made a zoom option, and then the object will go further away from the cursor,
I think dbMouseX() and the rest works at best when the camera is on top view or front view

Login to post a reply

Server time is: 2024-07-04 11:04:39
Your offset time is: 2024-07-04 11:04:39