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 / Can't make sprite face mouse completely?

Author
Message
Achilles
10
Years of Service
User Offline
Joined: 8th Mar 2014
Location:
Posted: 8th Mar 2014 23:27
I have been working on a Dark GDK project in which I make a sprite face the cursor or mouse's location. I picked up on some code and implemented it into my application but it seems to not be working correction. Here is a preview, http://gyazo.com/bf57df49071e3a684a7e03b8f0cf4527, as you can see, the sprite is not facing the right place where the cursor is and it does not move correctly. I believe this is because Dark GDK doesn't know where the center of my object is. Can anyone help me understand what I am doing wrong? I changed the values of the rotation and rotated the sprite but that didn't help at all.

Rudolpho
18
Years of Service
User Offline
Joined: 28th Dec 2005
Location: Sweden
Posted: 9th Mar 2014 12:11
Try dbPositionSprite(spr, dbMouseX() + dbSpriteWidth(spr) / 2, dbMouseY() + dbSpriteHeight(spr) / 2).

Sprite positions are relative to their upper left corner by default.


"Why do programmers get Halloween and Christmas mixed up?"

Login to post a reply

Server time is: 2024-11-18 21:31:45
Your offset time is: 2024-11-18 21:31:45