Hello All! My name is Ester. I have set out to create an Item Merger Game. At first I had no idea how to do this. It seemed pretty complicated. Spent many frustrating hours deleting codes. Then, it worked! I wanted to save you all the trouble since the code needed is so amazingly simple and I have seen unanswered posts on the forums before about how to do this. So, Here it is...
HOW TO CREATE AN ITEM MERGER: With Two Blocks of CodeFirst create a Drag & Drop Behavior with This Event:
Imput/Universal: On Actor (See attachment: event1.png -
You can ignore the if statements, they link to other functions in my game.)
When the mouse is (dragged)
set (x) to (((x) of camera) + ((x) of (mouse))) for (self)
set (y) to (((y) of camera) + ((y) of (mouse))) for (self)
Next, add this behavior to any object you want to drag around the scene. Next, add an instance of the following Event for every merge combination you need on each Actor:
Collissions: Type & Type (see Attachment: event2.png)
when a (Type1) hits a (Type2) --
create (Type3) at ( x: ((x) of (1st actor)) y: ((y) of (1st actor) ) at (Front)
kill (1st actor)
kill (2nd actor)
If this code doesn't work, I would make sure your collisions are setup properly. Ensure everything you need to collide is in a compatible collisions group. Also, if you are using collision boxes other than square, make sure to set your Game Settings/Settings/Advanced/Physics to Box2D. (see Attachment settingsPanel.png) You may be having failed collisions because Simple Physics only allow square collision boxes.
I hope this is helpful. Let me know if you get any good ideas for Item Merger games or how to simplify this code even more.
Have fun creating!
