Is there a way to associate an image to an attribute?

I want to display an image in front of a table value holding the score.
Is there any way to achieve this?

Thanks!

Comments

  • tatiangtatiang Member, Sous Chef, PRO, Senior Sous-Chef Posts: 11,949
    So you want to display the score (using tableCellValue(tableName,row,column) and then overlay a graphic on top of the text but have the graphic change depending on the cell value?

    It sounds like you're trying to do something like a custom score font. If so, there are tutorial videos available for that, but the basic idea is to save each digit as "1.png", "2.png", etc. and then do Change Attribute self.image to game.digit, assuming game.digit is the correct value.

    If you're wanting a different image to appear based on the score (e.g. >1000 pts show a star; >5000 pts show a trophy; etc.) then you would just make a rule for that based on the value of the table cell.

    Maybe I need more explanation about what you're trying to accomplish.

    New to GameSalad? (FAQs)   |   Tutorials   |   Templates   |   Greenleaf Games   |   Educator & Certified GameSalad User

  • tenrdrmertenrdrmer Member, Sous Chef, Senior Sous-Chef Posts: 9,934
    I think @tatiang has pretty well covered if but one other possible option I could see you might be looking for is you want to display and image and then like out the the right or the image have your score. For that your would basically need and actor for the score and and actor for the other image.

    but as previously stated we may need more info before we can really help you much.
  • knedyknedy Member Posts: 7
    Using custom font sounds like an excellent idea and and have started to research it.

    I am trying to create a pop-up message that displays an Image that says "SCORE" and the users current score next to it. I tried to use the display text behavior and concatenate the image to the table cell value which holds the score...

    image.png..tableCellValue(TB1,2,1)

    But this did not work. I thought an attribute representing the image would solve this. Is it possible to display images using display Text behavior?

    There are other elements that I want to incorporate into this pop up. Is it possible to use an actor to display several changing values and a continue button? or would I have to use a separate screen?

    Hope i explained myself clearly and Thank You guys for all the help!

    Knedy
  • tatiangtatiang Member, Sous Chef, PRO, Senior Sous-Chef Posts: 11,949
    It is possible to display an image and text using the DisplayText behavior, but not as you've suggested. You would have to assign an image using Change Attribute self.image to image.png and then use DisplayText to display the text in the vertical (and horizontal) center of the actor or the vertical top (enabling Wrap Text) of the actor. I don't recommend this approach because it's going to be tricky to get it to all align properly with whatever image you're using. There's not much in the way of customization for the layout of a DisplayText behavior.

    Why not just use separate actors? One for the word "SCORE" (either DisplayText or a static image) and one for the the actual score value (DisplayText).

    You can have something appear on the screen as a pop-up if you use the Pause Game behavior and put the actors on their own scene or you can move the actors from an off-screen location to an on-screen location or you can hide the actors using self.color.Alpha=0 until needed. In the latter cases, make sure the pop-up actors are in the highest layer so they show up on top.

    While Pause Game makes the process very simple, it makes your app slow in terms of the pausing and unpausing of scenes.

    New to GameSalad? (FAQs)   |   Tutorials   |   Templates   |   Greenleaf Games   |   Educator & Certified GameSalad User

  • The_Gamesalad_GuruThe_Gamesalad_Guru Member Posts: 9,922
    Also images can be addressed by name from a table.
  • knedyknedy Member Posts: 7
    @FryingBaconStudios
    I tried that. I followed tshirtbooths tutorial but i couldn't make it work for what I'm trying to do.

    @tatiang

    Thanks a lot! I used the self.color.alpha technique and it worked, with one exception. The score value in the display text behavior is not hidden for some reason. I made sure that the actor was on alpha=0. The background of the actor is hidden when the scene starts but the text shows. Am I doing something wrong?
  • tatiangtatiang Member, Sous Chef, PRO, Senior Sous-Chef Posts: 11,949
    DisplayText shows up even when the actor is transparent. Sorry about that! You'll need to wrap the DisplayText in a rule with a condition based on a boolean or the actor's position or whatever you are already using to determine when the pop-up should appear.

    New to GameSalad? (FAQs)   |   Tutorials   |   Templates   |   Greenleaf Games   |   Educator & Certified GameSalad User

  • knedyknedy Member Posts: 7
    I played around with it for a while and came up with the following:

    If game.popup is false display empty string, else display game.score value.

    It actually worked.

    Thanks again for your help!
Sign In or Register to comment.