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.

DarkBASIC Professional Discussion / Need help moving sprites with mousex() command

Author
Message
rolo9
16
Years of Service
User Offline
Joined: 1st Jan 2010
Location:
Posted: 9th Jul 2012 11:59
I want to grab a sprite with mousex(). When I use this command -

sprite 1, mousex(), 100, 1

it moves the whole sprite x(1) to the mousex() coordinates.

what I want to do is grab any part of the sprite with my mouse and not have the sprite automatically align with mousex().

this is what I have so far.



it grabs the sprite the first mouseclick() like it is suppose to. but as soon as I let off evrything goes weird. If anyone has a way to do this, I would be in your debt. Thanx
Chris Tate
DBPro Master
17
Years of Service
User Offline
Joined: 29th Aug 2008
Location: London, England
Posted: 9th Jul 2012 14:47 Edited at: 9th Jul 2012 14:48
Try using my drag and drop sprite example:



rolo9
16
Years of Service
User Offline
Joined: 1st Jan 2010
Location:
Posted: 10th Jul 2012 18:47
Thank You, Thank You, Thank You. By the way, did I say Thank You. I spent 14 or 15 hours trying to fix that. That works real good. One question tho? what is the purpose of

Sprite 1, Sprite X(1),Sprite Y(1), 1

after the last else statement? I used your code without it and it works still. I am just afraid that it will cause me trouble in the future. I really appreciate your help too. Thanx, rolo9
Chris Tate
DBPro Master
17
Years of Service
User Offline
Joined: 29th Aug 2008
Location: London, England
Posted: 10th Jul 2012 23:17
NP

In my application the sprite postion is taken from a user defined type array, so for each sprite in the array, position them according to their current setting. For example: Sprite Entity.SpriteId, Entity.x, Entity.y, Entity.Image

In your case, you wouldn't need the line, it serves no useful purpose if you are not storing the locations in variables.

Login to post a reply

Server time is: 2026-07-08 07:05:26
Your offset time is: 2026-07-08 07:05:26