How do I change image for a button

0 favourites
  • 4 posts
From the Asset Store
Simplistic hyper-casual game with nature elements. Tap to switch between the 4 elements and reach a better score.
  • In my game,I have a pause button with "pause" icon.If we click this button,game will pause and pause button will change to "play" icon (means if we click this button ,the game will resume).So how to do th at

  • Ha! It's freaking easy, dude..

    Let's consider that first state is play. And music is playing. So..

    var Button.State = 'play';
    <...>
    On Button clicked -->
         If Button.State = 'play' then {
              <pause music>;
              Button.State = 'pause';
              Button.Text = ' ► ';
              }
         Else if Button.State = 'pause' then {
              <resume playing music>;
              Button.State = 'play';
              Button.Text := ' ▌▌'
    [/code:hq50qlw4]
  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Sorry but i `m newbie with construct.so i `m not sure what you mean?So we must code in construct???how to do that???.You can explain more me?Button text can be an image: " Button.Text = ' ► '; "?

  • No, my code above is PSEUDOcode.

    So I understand you in programmable manner a sequence of your actions to do smth.

    To make this in C2 you need (let's disassemble my example):

    1. For object Button create string instance variable with name State. Its initial value must be initial state of your music. If pause - 'pause', if play - 'play'.

    2. Then create Event when you tap (with Touch plugin) or click (with Mouse plugin) this Button

    3. 1st sub-event of 2. event will be Button -- Compare instance variable with comparison Button.State = 'play'

    4. All sub-events of 3. event will be:

    4.1 Button -- Set value, pick State and set its value to 'pause'

    4.2 Button -- Set text and set text to ' ? '

    4.3 Any other actions to pause your music

    5. Then add another sub-event to 2. event: System -- Else and add new condition below Else - Button -- Compare instance variable with comparison Button.State = 'pause'

    6. All sub-events of 5. event will be:

    6.1 Button -- Set value, pick State and set its value to 'play'

    6.2 Button -- Set text and set text to ' ¦¦'

    6.3 Any other actions to play your music

    Do you understand so?

    Teach C2 and try to understand another's pseudocodes. I'll not write it so detail next time.

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