playMaker

Author Topic: Toggle between images  (Read 811 times)

wuannetraam

  • Playmaker Newbie
  • *
  • Posts: 17
Toggle between images
« on: October 06, 2020, 01:42:44 AM »
This is more of a basic logic question I think.

I have 5 buttons and 5 images. How I toggle between them now is like this:

if Button 1 is clicked
Image 1 = show
Image 2 = hide
image 3 = hide
etc

if button 2 is clicked
image 1 = hide
image 2 = show
image 3 = hide
etc

is this the correct approach? or is there a more efficient way?

heavygunner

  • Sr. Member
  • ****
  • Posts: 344
Re: Toggle between images
« Reply #1 on: October 06, 2020, 03:48:09 AM »
I'd set unique ID for each images. like 1,2,3,4,5
When Button#1 pressed that ID will be set to 1 (int) . same for 5 buttons.

Will send a common event everytime you click. That event will compare the ID (int) and display correct image

wuannetraam

  • Playmaker Newbie
  • *
  • Posts: 17
Re: Toggle between images
« Reply #2 on: October 06, 2020, 06:45:32 AM »
I'd set unique ID for each images. like 1,2,3,4,5
When Button#1 pressed that ID will be set to 1 (int) . same for 5 buttons.

Will send a common event everytime you click. That event will compare the ID (int) and display correct image
thanks for the response. Will the image that has been shown automatically hide again after a new button is pressed?

heavygunner

  • Sr. Member
  • ****
  • Posts: 344
Re: Toggle between images
« Reply #3 on: October 06, 2020, 10:50:00 AM »
I'd set unique ID for each images. like 1,2,3,4,5
When Button#1 pressed that ID will be set to 1 (int) . same for 5 buttons.

Will send a common event everytime you click. That event will compare the ID (int) and display correct image
thanks for the response. Will the image that has been shown automatically hide again after a new button is pressed?
yes. when you press button, that Int value will be changed and an event will be fired. It will compare int and display right image