How do I use sprites as buttons?

0 favourites
  • 6 posts
From the Asset Store
J-BoB Game Button Sound Pack comes with 300 high-quality sound effects
  • Hey Guys - Today i was challenging the GUI for my game. Usually i use Buttons to do that, but i would need to include sprites. I recognized, that it isnt that easy to use sprites as buttons, with the same characteristics of a construct2 button.

    Is there a simple way to do this? In my game you can tap on the whole screen, this will affect into some camera zooming. With the Construct2 buttons this was no problem, because the tap gesticure wouldnt be calculated as it will be if i use sprites instead. If the sprite buttons would work like a construct2 button (avoid input on my stage behind the button) - everything would be fine.

    Or is there a possability to change the Button style? And add a sprite instead of this grey background?

    Can someone help me out with this?

  • You could disable the zoom effect. Not sure how you coded it but you use "On overlap" or "is InTouch" with the sprite but invert it. So the zoom effect doesn't happen.

  • Option 1/ As you suggested yourself.

    Yes you can alter the style of a button.

    Use the action Button > 'Set CSS Style'. I did not use CSS myself yet.

    The codes this action needs you can find when you google on "CSS style text".

    Option 2/ Use sprites.

    There are a lot of technics to do this with sprites.

    Let me suggest just one. All GUI buttons go in 1 container. Create one of them to created them all when needed. Destroy one to destroy them all when they are no more needed. Choose one of those buttons to reference to. Lets say that button is 'TheOkButton'.

    Now the zoom you gots to cage with ...

    System > Compare two values > TheOkButton.count = 0. (if there are no TheOkButton sprites on the screen, the zoom can work.

    Then all the stuff you have in place to zoom.

    No clickable/touchable problems during normal gameplay, they are just not there.

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • So basically you were taking advantage of the fact that buttons did not trigger the "on tap" condition, while sprites do. To solve this, add a condition to your ”on tap"event - an inverted "is touching" spriteButton.

  • Hi, you can use Button behavior :

  • 99Instances2Go

    saad Swad

    oosyrag

    TheDom

    Thank you very much for your answers - i will try it out today. I will give you a Feedback if its working Nice ones!

    I dont want to use the CSS stuff for this project, so if i would get the sprites to work with the same characteristics - it would be absolutly nice!

    99Instances2Go would be a nice suggestion, but the buttons are visible the whole time the game is running. Currently iam working with the Plugins youve/Saad Swad sendet me (rex). But at the moment i couldnt figure out a solution.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)