Hey there! I've been trying to make a drag and drop planner, but I've unfortunately I'm pretty new at this and have been met with some challenges, and I haven't really been able to find answers on the forums or online either.
So, here's what I'm working with so far. What I'm trying to do is I'm trying to make it so that the little rectangles at the bottom can be dragged and dropped into the little time slot type things in the three columns at the top, and that once they're all in place, you can click "Done" to continue!
So far I've got the rectangles as draggable, and the button seems to work.
My main problem at the moment is....
I'm trying to make it so that if the rectangles at the bottom are placed anywhere but in the planner bars, they return back to original coordinates, and that if they are placed on the planner bars, they'll snap to fit into the planner's coordinates. How does one achieve such an effect?
Thank you very much!
Creating a Drag and Drop planner
Forum rules
This is the right place for Ren'Py help. Please ask one question per thread, use a descriptive subject like 'NotFound error in option.rpy' , and include all the relevant information - especially any relevant code and traceback messages. Use the code tag to format scripts.
This is the right place for Ren'Py help. Please ask one question per thread, use a descriptive subject like 'NotFound error in option.rpy' , and include all the relevant information - especially any relevant code and traceback messages. Use the code tag to format scripts.
- Adoxographist
- Regular
- Posts: 55
- Joined: Sun Apr 05, 2009 10:06 pm
- Contact:
Creating a Drag and Drop planner
Voice Actress and Artist
Free Voice Packs | Voice Acting Recruitment Thread
Check out my voice acting blog as well!
Free Voice Packs | Voice Acting Recruitment Thread
Check out my voice acting blog as well!
-
- Miko-Class Veteran
- Posts: 636
- Joined: Thu May 14, 2009 8:15 pm
- Projects: Castle of Arhannia
- Contact:
Re: Creating a Drag and Drop planner
to make them go into a specific location, use the snap() function in combination with the x and y cooridinate of your drops. to make them snap back when they aren't dropped on anything, you need to first check if the dragged rectangle was dropped on any of the drops and then snap it back to where ever it was originally, which requires knowing where it was originally. rather than trying to find out where it was, it's best to record it yourself or to use separate functions for each drag.
it would be easier to help if you posted your actual code, but here's about what it would look like if you use the above method:
it would be easier to help if you posted your actual code, but here's about what it would look like if you use the above method:
Code: Select all
screen planner:
#background and labels added here
draggroup:
#slots should be drops
drag:
#child, drag_name etc. as needed
draggable False
# pos
#repeat for each slot
#then the rectangles as drags
drag:
drag_name #something unique to identify it with
#child, etc. as needed
droppable False
dragged rectangle_dragged
# pos
#repeat for each rectangle
init python:
def rectangle_dragged(drags, drop):
if not drop:
#check which rectangle it is, and snap it back to it's spot
return
else:
drags[0].snap(drop.x, drop.y)
#record the information indicated by that rectangle and that slot
# use drop.drag_name if you need to know which individual slot is involved
return
- Adoxographist
- Regular
- Posts: 55
- Joined: Sun Apr 05, 2009 10:06 pm
- Contact:
Re: Creating a Drag and Drop planner
Thank you very much for your help! It works like a dream.
I'm still having a bit of trouble with the planner (particularly how to make it so only one drag can be dropped into a certain area, and if another object is there, it'll move back to it's original position) but since it works for now I guess I will move on to other stuff.
Thank you so much again. OVO!!
I'm still having a bit of trouble with the planner (particularly how to make it so only one drag can be dropped into a certain area, and if another object is there, it'll move back to it's original position) but since it works for now I guess I will move on to other stuff.
Thank you so much again. OVO!!
Voice Actress and Artist
Free Voice Packs | Voice Acting Recruitment Thread
Check out my voice acting blog as well!
Free Voice Packs | Voice Acting Recruitment Thread
Check out my voice acting blog as well!
Who is online
Users browsing this forum: Google [Bot]