Jump to content

Image, Button or Sprite?


Dio
 Share

Recommended Posts

Hi,

I would like to understand which option should I choose for a clickable image: My assumptions are: if I want my "button" to participate in physics, I should go with a Sprite. If my "button" does not involve physics, I can choose either Button or Image. Button from images differs that they have functionality to show different image frames for different states of a button (out, over, up). If I do not want my button to have different states, i should go with Image.

Are my assumptions correct? Can you provide more real life scenarios when you have chosen one type of clickable image or the other and reasons behind that decision.

For example, currently I would like to implement inventory item which is a rectangle shaped image. When user clicks it, button should show that the inventory item is selected by showing a dashed red rectangle with rounded corners around the item. As I understand, I should go with Image because I need "selected" state, which Button does not currently have and I have to implement it myself anyway. I do not know whats the best way to implement that dashed rectangle around the inventory item though - I would like to have it reused since all inventory items presumably have the same dimensions.

 

Link to comment
Share on other sites

Hey! That sounds about right to me. Or, at least, that's what I've been doing in my games and it's worked so far. ( =

As far as button not having a selected state: it *does* have enough signals (onInputDown, onInputUp) that you could set the selected state yourself. Ignore the constructor and GameObjectFactory parameters and set it manually, maybe in a derived class yourself. Does that make sense?

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...