Flip image, flip button?
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller
Flip image, flip button?
Hello,
I have a code where with a random chance of 50 % an image flips
"if random(1000)<500 then flip image who horizontal"
I want to do the same with a button(which has an image on it).
Is it possible? Because with the same code it said error.
Best regards
Mark
I have a code where with a random chance of 50 % an image flips
"if random(1000)<500 then flip image who horizontal"
I want to do the same with a button(which has an image on it).
Is it possible? Because with the same code it said error.
Best regards
Mark
Re: Flip image, flip button?
Hi Mark,
the icon of a button is only refreshed when you click the button.
To do what you want set the icon of the button to the id of the image you just flipped.
Like this
Kind regards
Bernd
the icon of a button is only refreshed when you click the button.
To do what you want set the icon of the button to the id of the image you just flipped.
Like this
Code: Select all
on mouseUp
lock screen
put random(1000) into tNumber
if tNumber < 500 then
flip image "myImage" horizontal
set the icon of button 1 to the id of image "myImage"
end if
unlock screen
end mouseUp
Bernd
Re: Flip image, flip button?
you could also script
instead of the "id of image "myImage""
Kind regards
Bernd
Code: Select all
set the icon of button 1 to the icon of button 1
Kind regards
Bernd
Re: Flip image, flip button?
Hello,
This doesn't work like I want it to be (or I couldn't do it right).
I have a start button which spawns 1-10 random enemies. These enemies were images before so I had no problem flipping them.
When I clicked the start button, some of the enemies faced the right side and some the left side.
Now I changed the enemies to a button with the same image, but when you hover or click the button('enemy') the image changes[So it has a little effect].
Now I want to flip those random enemies but with that code you wrote, it flipped all the same, so either everyone got flipped, or none.
But I wanted it to be random so for example 3 are looking right, 4 are looking left.
Hope I could explain it well
Best regards
Mark
This doesn't work like I want it to be (or I couldn't do it right).
I have a start button which spawns 1-10 random enemies. These enemies were images before so I had no problem flipping them.
When I clicked the start button, some of the enemies faced the right side and some the left side.
Now I changed the enemies to a button with the same image, but when you hover or click the button('enemy') the image changes[So it has a little effect].
Now I want to flip those random enemies but with that code you wrote, it flipped all the same, so either everyone got flipped, or none.
But I wanted it to be random so for example 3 are looking right, 4 are looking left.
Hope I could explain it well
Best regards
Mark
Re: Flip image, flip button?
Hi Mark,
since icons in buttons with identical IDs always display the SAME image (no instance or whatever!)
and if you modify (flip in your case) that image, the cahnge will be reflected in all buttons that have
this images as icon!
Simply make a copy of your image and flip that one so you can use this as the "flipped" icon while
preserving the "original" unflipped image!
Best
Klaus
since icons in buttons with identical IDs always display the SAME image (no instance or whatever!)
and if you modify (flip in your case) that image, the cahnge will be reflected in all buttons that have
this images as icon!
Simply make a copy of your image and flip that one so you can use this as the "flipped" icon while
preserving the "original" unflipped image!

Best
Klaus
Re: Flip image, flip button?
Hey,
thanks for the help! I got it to work now
Best regards,
Mark
thanks for the help! I got it to work now

Best regards,
Mark