Page 1 of 1

null

Posted: Mon Mar 30, 2020 12:13 am
by Kiyo
null

Re: How to add a button/icon for in-game minigame?

Posted: Mon Mar 30, 2020 1:29 am
by Per K Grok
Kiyo wrote:
Mon Mar 30, 2020 12:13 am
How to add a button/icon for in-game minigame?
I am planning to add a minigame for my game, and I want the player to be able to play the minigame by clicking the minigame icon. How can I do this?
Please help me.
To make a button you need a screen to place the button in. You could do something like this.

Code: Select all

screen minigamebutton():
	imagebutton idle "MGbutton.png" action Jump("minigame") pos (10, 10)

You can place that piece of code somewhere before 'label start'.

You will probably also want a hover image and maybe some more stuff. Read up on 'imagebutton'.

For the button to show up in the game you need to put this line of code in the code at the point where the button should start to be seen.

show screen minigamebutton

and the button will now be seen in the position 10 pixels from the top and the left sides of the game screen (or whatever position you chose).

And if there is some part of the game where the button should not be seen you add this line of code

hide screen minigamebutton

---------

With the code above clicking the button will take you to a label (label minigame) where you have your minigame.

This could be a bit of a problem if you want to jump back to the spot you where at when you clicked at the button. It is no problem if you always continue to a specific label.

Another way would be to have the minigame in a screen (you will need a screen for your minigame anyway) and instead of jumping to a label you show the screen.

replace Jump('minigame') with Show('minigame)

This will open a 'screen minigame()' where you have your minigame. When you close the minigame (hide the screen) you will be at the same spot.

--------

This was in no ways a complete description on what you need to know, but hopefully it is enough to get you started.
Read up on screens, screen language and actions. You will need that to make a minigame. Good luck.

Re: How to add a button/icon for in-game minigame?

Posted: Mon Mar 30, 2020 10:20 am
by Kiyo
Per K Grok wrote:
Mon Mar 30, 2020 1:29 am
Kiyo wrote:
Mon Mar 30, 2020 12:13 am
How to add a button/icon for in-game minigame?
I am planning to add a minigame for my game, and I want the player to be able to play the minigame by clicking the minigame icon. How can I do this?
Please help me.
To make a button you need a screen to place the button in. You could do something like this.

Code: Select all

screen minigamebutton():
	imagebutton idle "MGbutton.png" action Jump("minigame") pos (10, 10)

You can place that piece of code somewhere before 'label start'.

You will probably also want a hover image and maybe some more stuff. Read up on 'imagebutton'.

For the button to show up in the game you need to put this line of code in the code at the point where the button should start to be seen.

show screen minigamebutton

and the button will now be seen in the position 10 pixels from the top and the left sides of the game screen (or whatever position you chose).

And if there is some part of the game where the button should not be seen you add this line of code

hide screen minigamebutton

---------

With the code above clicking the button will take you to a label (label minigame) where you have your minigame.

This could be a bit of a problem if you want to jump back to the spot you where at when you clicked at the button. It is no problem if you always continue to a specific label.

Another way would be to have the minigame in a screen (you will need a screen for your minigame anyway) and instead of jumping to a label you show the screen.

replace Jump('minigame') with Show('minigame)

This will open a 'screen minigame()' where you have your minigame. When you close the minigame (hide the screen) you will be at the same spot.

--------

This was in no ways a complete description on what you need to know, but hopefully it is enough to get you started.
Read up on screens, screen language and actions. You will need that to make a minigame. Good luck.
Thank you :'>