This forum is read only and just serves as an archive. If you have any questions, please post them on

1 decade ago by OMATASE

I want to make a target selection feature, where a player can click on any one of 8 entities to choose that particular entity as a target for an action.

I'm not sure if creating a target selection entity / HUD is the best way to go about this but it is the best method I can think of.

The idea is that during target selection mode additional HUD elements would appear on the screen. One of the HUD elements would be like a "select all" button that would appear above all target entities. Instead of the "select all" button, they could click on an individual targetable entity as well.

In other game modes (not the target selection mode) it is possible to select certain entities but not all. During target selection you will be able to target virtually all entities so I need some way the entities can discover whether I'm in target select mode or not so that they will make themselves clickable. I also want all available targets to glow or light up when in target select mode, I'm not sure how I'll do that. I want the target selection entity to know which entities are valid targets, I don't want the targets themselves to have to know that. It would be cool if the Target Selection Entity to find relevant target entities and call a method on them telling them to glow. That way the logic stays in my target selection entity.

Any help is much appreciated.

1 decade ago by OMATASE

With the intention of going back and modifying my code if I get a good suggestion in here I have moved forward trying to implement this without yet receiving any input. What I've done works well but it seems like there is a better way to go about this. I'm used to doing more event-based design but I'm not familiar enough with javascript to know if what I'm doing could be done in that type of a system or if there is a third, better way to do it.

What I've done is I've used the method in my target selection entity to get all character entities (these are all valid targets). Then I call a method on these to change their state. This state change tells them to glow. Then if one of them is clicked when in a "glow state" (this is where it gets a bit stringy IMO) the character uses the target selection reference in my game class ( to call a method indicating a target was clicked. Now it gets even wonkier because the tarSel does some logic at this point to ensure the selected target is valid, then if it is it calls back to the character again to tell it that it's the selected character which causes the character to display differently showing a selected state.

All this passing back and forth seems like it will become a maintenance nightmare. I am going to change the character class to raise an event when clicked so that the target selection entity can be informed via event registration but is there a better way or is there more I could do to smooth this out?


1 decade ago by orubel

An event class to handle all events from 'player' would be good. This way player, objects, etc can be clickable for interaction, pathing, or for creating a HUD. So keyboard, mouse clicks and touch screen events all go through one class and are handled in a similar fashion as on/off/over/out based on X/Y coords.

As for a Hud, this would work well with canvas capabilities in creation of other canavas layers so that you can 'popup' communication boxes, drag/drop elements, create an interactive interface, etc.
Page 1 of 1
« first « previous next › last »