How it works...
Four UI Image objects Image-star0/1/2/3 have been created at the top of the screen — initialized with the gray placeholder icon. The gray and yellow icon sprite files have been resized to be 100 x 100 pixels, making their horizontal arrangement positioning at design time easier, since their positions are (0,0), (100,0), (200,0), and (300,0). In a more complicated game screen, or one where real estate is precious, the actual size of the icons would probably be smaller – a decision to be made by the game graphic designer.
In script class PlayerInventory, the int variable totalStars represents how many stars have been collected so far; it is initialized to zero. The variable playerInventoryDisplay is a reference to the scripted ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access