pop-up menu

irosenirosen Member, PRO Posts: 6

Im trying to figure out how to do a simple popup menu. I see this older post - but it is no longer available.
https://forums.gamesalad.com/discussion/9878/simple-popup-menu-demo

I can see 2 ways to do this.
First, when my actor is touched, spawn the two buttons off to the side. The challenges I see are if I click on one of the two buttons, how does the button not touched get destroyed (think one button is delete the main actor, the other is upgrade - tower defense type game). Also if one of the buttons overlap with the main actor, the touch applies to all actors.

the other way would be one graphic that has both buttons and i just calculator based on position and size which button was pressed..then i could destroy the single button actor regardless which button was pressed.

Any good ways people have used to solve this?

Thanks!

Comments

  • bob loblawbob loblaw Member, PRO Posts: 793

    if i am reading your post right, you want a menu that slides on and off the screen when a fixed/hud button is pressed?

    have an attribute (call it "menuActive" for the purposes of this). set your menu button to alternate between 0 and 1 whenever it's pressed.

    for your menu actors, set them off the scene (to the left or under) to start. have a behaviour in the menu, and any things like buttons that sit on it, to move into position when menuActive = 1, and to move to their off-scene position when menuActive=0.

    hope that makes sense.

    i will be tied up at a funeral all day tomorrow, but if i get the chance sometime after, i will try dummy up a basic demo for you to pick apart and learn from.

  • irosenirosen Member, PRO Posts: 6

    thanks for the comment. That makes sense, but I still am not sure how to do the following. I have a turret, that can be destroyed or upgraded. If I click on the turret, what you wrote above makes sense, I can slide them on the screen next to the turret. If I click the upgrade button, I can make that slide away, but how do I get the other button to slide away (the remove turret button that was not pressed). Im thinking I need some number of flags and logic that each button can use to determine if the buttons are slid out, but the other button was pressed..so that unpressed button can slide away as well..does that make sense?

    thanks!

  • irosenirosen Member, PRO Posts: 6
    edited June 2019

    I got it working by moving the buttons on / off screen. I think its the spawn/destroy that was causing unexpected issues - the logic I think was sound, but it seems destroying actors probably caused things to fire in an unexpected way. If there isnt any issue with leaving a few actors off screen, this is good enough. Thanks!

  • Elizabeth333Elizabeth333 Member Posts: 1

    That makes sense, but I still am not sure how to do the following. I have a turret, that can be destroyed or upgraded. If I click on the turret, what you wrote above makes sense, I can slide them on the screen next to the turret. If I click the upgrade button, I can make that slide away, but how do I get the other button to slide away (the remove turret button that was not pressed). kroger survey

  • famekraftsfamekrafts Member, BASIC Posts: 834

    Use a game attribute which is true or false. When you click on any button, it makes it true and when true both the buttons slide away,

    if false and you click the button to pull them on screen, they slide back on screen.

    The logic is very easy, I believe.

    I have used spawn actor as well, but if you can avoid it is better.

  • irosenirosen Member, PRO Posts: 6

    here is a version with multiple "turrets". My problem now is I have a gun base and a turrent - I can delete the gun but it leaves the base behind. its really hard to affect other objects or treat things as a group of objects.

  • tatiangtatiang Member, Sous Chef, PRO, Senior Sous-Chef Posts: 11,949
    edited June 2019

    @irosen The demo you posted is a bit hard to follow. The actors don't have names, everything is the same color (white)... and you also have a missing attribute in at least two of the actors. Can you explain what's supposed to happen vs. what is happening? Or post an updated version that's a bit more self-explanatory?

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

  • irosenirosen Member, PRO Posts: 6
    edited June 2019

    Ok - i fixed up the demo - this shows how you can have multiple turrets (actors) on screen and click on one to display two buttons. When either button is clicked, both buttons move off screen. The result of the button press is shown in the display (you would replace this with deleting or upgrading the turret.) If you press on the turret again (not a button) the pop up menu buttons go off screen without any action.

    Ive found that you if you want to associate the action with the button, you do need to give each turret an index number that you would store in a game level attribute and set when the turret is initially touched.
    HTH

  • tatiangtatiang Member, Sous Chef, PRO, Senior Sous-Chef Posts: 11,949
    edited June 2019

    Okay, that makes more sense.

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

  • tatiangtatiang Member, Sous Chef, PRO, Senior Sous-Chef Posts: 11,949

    Do you still need help?

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

  • irosenirosen Member, PRO Posts: 6

    nope, its all working now..on to the next challenge :smile:

Sign In or Register to comment.