Stencyl 3.4.0 is now out. Get it now!

How to make buttons to switch scenes on click?

Kastex

  • Posts: 35
i want to make a title screen with buttons (like play, instructions, options, ETC). i'm not exactly sure how to go about doing this.

i was thinking maybe the buttons should be actors that i place on the screen and make behaviors that switch the scene once clicked. is this a good way to go about it?


squeeb

  • Posts: 953
Best way is actors... I use regions the same way instead of actors... just when testing.. create the regions in scene.. and when you click on region switch scene...or just add touch/click mouse to change scenes as well..if you only need one "button" polished look is way better with actors. I add them back in later

Kastex

  • Posts: 35
so how do i make a behavior for the actor on click to change to a specific scene?

squeeb

  • Posts: 953
There's a block that switches to a scene.. do a mouse  event when pressed or released ect... and find the switch to scene block and use it in that event

Kastex

  • Posts: 35
thanks. i've managed to make buttons switch scenes successfully. now i am wondering how i can make a button to glow when the mouse hovers on it. i already have the button actor types for an inactive button and the glow button when hovered over.

the problem i am having is i'm not sure exactly how i'm going to make the glowed button show when the mouse hovers. i have a few vague thoughts on how this can be done, but i'm not sure exactly. any ideas?

squeeb

  • Posts: 953
You can set opacity levels when the mouse is over the area... or what I usually do is have seprate events.  1 for mouse over to glow?  I haven't done this yet.  Shouldn't be hard.. mouse pressed switches the animation of the button to one that looks pressed and loads scene
VVV  @TheIndieStation  has great tutorials!!

« Last Edit: April 19, 2017, 04:24:00 pm by squeeb »

TheIndieStation

  • *
  • Posts: 2119
Check out the first part of my basic race game tutorial series. You can find a link to my channel below this message

JeffreyDriver

  • Posts: 966
There's different ways of going about this. You can switch to a different animation, or use different effects.

Here's some code I have in an actor behaviour that makes a button flash on mouse over.

Kastex

  • Posts: 35
thanks everyone. i actually found out how to do this yesterday after my last post, but i also wanted to know about more methods anyway. your methods will help me and maybe others in the future. and thanks indie for your tutorials i was thinking about maybe making some sort of racing game in the future. your platform tutorial is actually helping me a lot on my current project.

what i ended up doing since i already had the actor PNGs for inactive and active button was rename the stock "Animation 1" and "Animation 2" to "inactive" and "active". then i made a behavior for when the mouse enters the actor to switch to the active animation and when the mouse exits the actor to change back to inactive animation. i made it an actor behavior instead of using events so i can put it on multiple buttons and all i need to do is make sure to rename the animations to active and inactive for each button. for actor events i made events for scene switching.
_________________________________________________________________________________________

i am having one more problem though. i find it quite difficult to make icon buttons. the buttons i've made so far were simply words like "play" or "back", but in-game i will need to utilize icon buttons for their smaller size and modernness. i'm new with photoshop and i'm not sure exactly how i'm going to make icon buttons.

i tried using free game assets from websites and i even looked for button icons on pexels and pixaby. the problem i am seeing with that is they have multiple buttons in the same picture. will i just have to use ps tools to crop out other buttons in a picture?