Pop up Image

Lindsay44Lindsay44 Member, PRO Posts: 16
So in my game I have clickable animals that make noise when touched, but I would also like when you click them a separate box to pop up at the top of the screen with the animal name in in, ex "DOG". How do I do something like that, I have been working at it for days, and have hit a road block it seems ... I have many animals per screen (four scenes total) and I want the name plate to disappear after a couple seconds.


Thanks :)

Comments

  • jonmulcahyjonmulcahy Member, Sous Chef Posts: 10,408
    this is what I would do (and have done something similar)

    create two attributes:
    animalName = text
    showAnimalLabel = boolean

    put your label actor just off screen. in it have a rule that says

    when showAnimalLable = True
    interpolate self.position.y to XXX - where XXX is a position on screen you can view it
    timer: after 3 seconds
    change attribute game.showanimalLabel = FALSE
    otherwise
    interpolate self.postion.Y to XXX - offscreen position

    have another rule in the label actor

    displayText animalName
    (you could get fancy and use images instead)
    constrain attribute self.image to animalName
    (for this to work, if you were trying to display dog, your image file would have to be called dog.png)

    then in the animal actor itself

    when touch is pressed
    change animalName to (whatever you want here)
    change showAnimalLabel = true


    that should do what you want


  • Braydon_SFXBraydon_SFX Member, Sous Chef, Bowlboy Sidekick Posts: 9,273
    Not that hard when you think about it. I find that taking a piece of paper and writing out all of your thoughts in your head does wonders. For me, I know how to do a certain bit of code, but I need to see it visually in order for me to figure out what things go where. I don't do this all of the time, only when building large game mechanics....Anyway, back to your subject. ;)

    Create a table and create as many columns (or rows) as you have animal blocks.
    Fill each one with the animal name. For example, if the first animal (from left to right) is a penguin, in your table (column 1) write "penguin."

    You'll need to create a boolean attribute that will turn to true when any animal is pressed.

    In your popup box actor:
    When boolean attribute is true,
    Display text: tableCellValue(game.AnimalTableName,X,Y) ---- X is the row of that animal name, Y is the column of the animal name.

    Interpolate: self.Color.Alpha to 1 (duration is up to you).

    OTHERWISE:
    Interpolate: self.Color.Alpha to 0 (duration is up to you).

    Also inside your box actor:


    In a separate actor, preferably one that controls other things in the game, like scene changes, scores etc:

    Rule: When attribute boolean attribute is true,
    Timer: After x amount of seconds,
    Change Attribute: game.boolean attribute to false

    Hopefully that puts you on the right track...
  • Braydon_SFXBraydon_SFX Member, Sous Chef, Bowlboy Sidekick Posts: 9,273
    Hey @jonmulcahy‌ - You and I just keep posting and answer questions right after another haha.

  • jonmulcahyjonmulcahy Member, Sous Chef Posts: 10,408
    Hey @jonmulcahy‌ - You and I just keep posting and answer questions right after another haha.

    i know, busy day on the forums
  • Lindsay44Lindsay44 Member, PRO Posts: 16
    @Braydon_SFX‌ I see you guys have lots of helpful videos, on tables. Do you have any up that would help in this situation ? The directions that you gave me are awesome, but just in case.
  • Lindsay44Lindsay44 Member, PRO Posts: 16
    So i asked this already, and got great answers but I still can't figure it out. Below I have attached an image of one of my screens. I want when you click an animal there to be a banner in the sky with the title of the animal. "FOX"/"DEER". I was told to use a table, but I can't figure it out (been working at it for about 4 hrs now )... Is there anyone that could basically spell it out for me.
  • jonmulcahyjonmulcahy Member, Sous Chef Posts: 10,408
  • jonmulcahyjonmulcahy Member, Sous Chef Posts: 10,408
  • tatiangtatiang Member, Sous Chef, PRO, Senior Sous-Chef Posts: 11,949
    [merged threads]

    Please don't create multiple threads for the same issue.

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

  • Lindsay44Lindsay44 Member, PRO Posts: 16
    @jonmulcahy Thanks so much, thats awesome!!! so helpfull :)

    @tatiang‌ sorry, won't happen again :(
Sign In or Register to comment.