[Soved for x]One Button Switch between 3 or 4 items

0 favourites
  • 8 posts
From the Asset Store
Design for game, asset for game, game kit, UI design, completed design for game, mobile game, Dashify Switch
  • I want something to switch my images like switching themes, but I want only one button to cycle through choices.

    Ive got

    global

    var frame = 0;

    System.start of Layout

    color1 set animation speed to 0

    then

    On button clicked

    color1 set animation frame to 1

    //subevent

    System/frame=1 color set animation frame to 2

    System/frame=2 color set animation frame to 3

    System/frame=3 color set animation frame to 4

    It doesn't really work. It goes from 0,1,4, instead of 0,1,2,3,4

    maybe I need an array?

    Thanks Anyone.

  • Need to use 'else'.

    Right now 'set to 1' makes '= 1' true. If true it is 'set to 2' and that makes '=2' true. And so on.

  • Yes that makes a lot of sense thank you.

  • Yep That's what I needed thanks again.

    whoops I need one more. animation frame to 0 so it will loop back through the selections.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • What if I wanted to use 'set layer background color'

    to this system choice loop thing.

    Or css style or anything other than animation frames?

  • Then you just do, as long as you do not need to pick instances any action will be fine.

  • As long as your numbers are in order, you can also use an incrementing value, like so:

    Button On Clicked

    AnimationFrame < 4 - Set Animation Frame to Animation Frame+1

    Else - Set Animation Frame to 0

    Or to be extra compact, you can use a conditional operator (advanced):

    On Clicked - Set Animation Frame to Sprite.AnimationFrame<4?Sprite.AnimationFrame+1:0

  • Well I went from using a sprite, to just changing the background color for now, and adding some .css to it instead of images.

    Seems better on performance?

    You guys got me thinking though.

    *I keep forgetting to set instance variables.

    But I don't think you can set one for "background" so I probably go back to images.

    Thanks Guys.

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