Real Software Forums

The forum for Real Studio and other Real Software products.
[ REAL Software Website | Board Index ]
It is currently Tue Nov 19, 2019 11:32 pm
xojo

All times are UTC - 5 hours




Post new topic Reply to topic  [ 3 posts ] 
Author Message
 Post subject: How to Drag and Drop Simple (2D) Sprites
PostPosted: Wed May 27, 2009 8:10 am 
Offline

Joined: Fri Sep 30, 2005 1:53 pm
Posts: 914
Location: Philadelphia, PA
Thanks to comments through another thread (viewtopic.php?f=4&t=27998), I'm able do the following: (1) I can have an object with an irregular outline (i.e., have a "sprite") move from one position to another without messing up the background. (2) (I can "animate" that "sprite." (3) If someone clicks on a square, I can also tell whether it is empty or what particular game piece it contains. That's a lot that I couldn't do a week or so ago.

Other than come up with (or create) the graphics for appropriate game pieces, my only other objective at the moment is to figure out how to do "drag" and "drop" for the "sprites" (assuming it can be done).

Any advice (or, better yet, specific examples) on how to do it? Thanks again for the help!

Barry Traver


Top
 Profile  
Reply with quote  
 Post subject: Re: How to Drag and Drop Simple (2D) Sprites
PostPosted: Wed May 27, 2009 9:45 am 
Offline
User avatar

Joined: Sat Jun 16, 2007 11:37 pm
Posts: 93
Location: Oxford, NC USA
It sounds to me like you have most of what you need already to be able to "drag n drop" a sprite. Seeing you already know what tile is clicked, apply that same detection to a sprite. You already know where they are, so do some bounds checking when you click down on the screen and see what is there. Add a function to the sprite class to detect if it was clicked on and return if it was or not. If it was, then allow the mouse to reposition the sprite based upon its travel distance and direction. You might consider adding a flag that captures the sprite as being in the drag mode. You will need to know which sprite is being moved around for the next screen update and to be able to continue dragging it about the screen. Be sure to check for the mouse up event to determine the end of the drag so it will effectively drop it. You will just need to use the mouse movement to add/subtract the difference from the starting sprite position.

_________________
-- computercoder


Top
 Profile  
Reply with quote  
 Post subject: Re: How to Drag and Drop Simple (2D) Sprites
PostPosted: Wed May 27, 2009 11:14 am 
Offline

Joined: Fri Jan 06, 2006 3:21 pm
Posts: 12388
Location: Portland, OR USA
Take a look at the DragPics example that comes with RB. It's in Examples/Graphics/DragPics under your RB installation.

Tim


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 3 posts ] 

All times are UTC - 5 hours


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  
cron
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group