Hello to all i just ask if anyone implement or create a List for some objects in the screen for example list of Level o Objects for invenctory or ecc i have no idea to start
Create UI with FP, List of Objects
I believe the best way to do this is with a MVC paradigm.
Youāll want a couple of classes: ListController
and ListItemRenderer
. The list will be composed of several ListItemRenderers
which will be managed with the ListController
.
If you have more questions, let me know and weāll talk through it! Iāve not created one of these in FlashPunk yet, so itāll be good experience for both of us.
and if we use the logic of camera? for example we have an entity List with Viewport and a list of other Entities ok? Now when we create a list we give to the constructor the Height of List FOR VIEW and set it to viewport. Now i donāt know if we can create a Mask visible in a entity but if we use the viewport for Mask of View of list we can add and move the entities into the list (with Y cord) and view these ONLY into the viewport no? itās a simple idea :3
Now, do you want the list to be a part of the UI (like an RPGās items menu), or do you want the list to exist āin the worldā? If you want it to sit on top of everything, you want to draw it to the same screen location every time.
nono the list need to be an Entity :3 so i wanna that into the World class
I think @fedyfausto is talking about an actual list of items, like a store list or skills list.
yes zach :3 the only idea i think its the use of an Viewport for an object what contain the other objects listā¦ and scroll them of Y cord if we press a button or otherā¦
Letās entertain that idea for a moment. Keyboard selection is no problem, but how do we detect which item was clicked by the mouse? We would need a way to perform a hit test on each graphic. I suppose we could create a ListItemRenderer
class that holds a Graphic
and a Mask
, then on adding children, we could add those to a Graphiclist
and Masklist
and run a hit check against the Entity
's masks.
What do you think about that? Would individual Entity
s be better than this solution?
Ideally you could nest entities but I think this would be the simplest solution. The layout for your ListItemRender looks will determine the hit complexity, but most standard vertical or horizontal lists could just use a standard tile map picking approach to find the correct index when the parent is clicked \ hovered etc.
Another thought for a large inventory (thinking grid-type thing) you may want to use a Canvas to reduce draw calls, and when you blit each icon you could store all the rects into an array for containsPoint collision, reduces the complexity of accounting for padding when calculating the correct position - at the cost of iterating a whole array every frame, but always optimize later.
I wouldnāt mind exploring this more. Should we continue this thread or start a new one more aptly named, like HUD?
A new topic to discuss specific controls would be appropriate.
Iād suggest you starting off with your high-level concept in the feedback category, and weāll wax poetic there.