Drag and drop if
-
I need to create a toolbox of sorts. So you drag an item out and it allows moving around the screen. But I need to limit the number of times an object can be added. So you could put three of that item on screen and then no more would be available.
-
-
Make your toolbox. Space each of the objects the same distances apart, and use position and other visual calculations to make everything very organized. Organization is extremely important, and will make all the difference to a user.
-
Personally, I like to distribute behaviors separately into each object. It takes a long time and it is not too efficient either; it's just way easier to work with. You can also put all of the behaviors inside of one object (this would be using objects tags as well), and group them conditionally; that would be more efficient and faster, too. It would just be harder to keep track of. You have to decide how you will group your behaviors, and then you can actually go one with the process.
-
Make sure each of the objects are draggable, and organize in a way that you can turn this behavior off later.
-
Use attributes to figure out how many times an object has been dragged onto the screen.
-
I like to put this logic under a started touching label. I also like to dispose of objects if they stay inside of the toolbox or are out of screen parameters; you would have to subtract from the attributes though in order for them to still be valid.
-
Put these objects on some type of grid: this is another additional step that will help keep your editor organized. You can search up different types of grids or look for examples on the hub. Some ideas are rounding or flooring, using sinus functionality, or using division and a function's modelo - honestly, there are many different possibilities depending on what you are looking for.
-
Develop your behaviors in a way that you can add to them in the future. If you would like to include an additional editor that users can use to transform the object or if you want to allow users to put different settings into effect, you will have to leave space for that (examples: scaling objects, moving them using arrows, allowing more/less of a type of object, creating physical properties for that object, etc, etc.)
-
Test. test. test. Always keep your users in mind, but remember that they won't see anything behind the scenes (take advantage of that!)
If you would like more help, feel free to reach out to me.
-
-
How would I set the actions up to get the response I need?
-
Here's an example:
For each object:
Create a separate drag and drop behavior.
Say if stopped touching, get object position. Then use ifs to calculate whether the position of the object is too small or too big x and y. If it is, make the ifs trigger a destroy object. Next to the ifs, include the grid functionality, and next to the grid functionality, you can insert the attribute logic (all under the get object position behavior).
The grid functionality: you can just round the position if you want, x and y. Then move the object to that location.
The attributes: create an attribute for each object, and under those object's behaviors, add 1 to that attribute. Also, check to see what the attributes already are. If there are too many objects, delete them, and maybe trigger some type of pop-up.
Again, this is the way I do things. It is not efficient, and you should try to figure out a way to just include all this functionality inside of one logic object.
-
Ok. Thanks! What if I want to not allow dragging if a certain value is reached.
-
Kind of like hyper pad uses for attributes drag to screen but with a limited number of times
-
@Robertiii Just turn the drag behavior off instead of deleting the objects (once you get to the attributes)