This site requires JavaScript, please enable it in your browser!
Greenfoot back
JordiC
JordiC wrote ...

2019/5/28

Help With Droppable Characters from a menu.

JordiC JordiC

2019/5/28

#
Hi !!! I'm trying to make a sort of plants vs zombies type game, but I don't know how i'd go about dropping actors from a menu. Where should I start?
Super_Hippo Super_Hippo

2019/5/28

#
I am not sure how I would do it. There are several ways. For example: -- Have one class for the plants. No matter if they are shooting, dragged to a possible position or in the menu. Have a variable to track what it is doing right now and act accordingly. So have it start at 0 (=in menu). When clicked, add a copy with 1. At 1, follow the mouse. If clicked at a possible position, "drop" it, set the variable to 2. If at 2, shoot, react to being attacked… -- Have one class for the plant in the menu (menuPlant) and one for the plant on the field (fieldPlant). The world handles which object in the menu is clicked on and this object follows the mouse. If clicked again at a possible position, a new fieldPlant object is created at this position and the menuPlant moves back to where it came from.
You need to login to post a reply.