ok i want one of my sprites to work as a button.
so lets say that sprite 1 says hello when mous-pointer touches it but then i want to change sprite 1 reaction to the mouse-pointer if sprite 2 have been pressed.
how do one do that?
thank you,
A.
Offline
It's easy; use a variable.
Create a variable named "setting". Put this script in your button:
when gf clicked set [setting v] to [1] when [Sprite2] clicked change [setting v] by (1) set [setting v] to (((setting) mod (2)) + (1)) // Change the 2 to your amount of possibilities.Put this in Sprite1:
when [Sprite1] clicked if <(setting) = [1]> say [hello] end if <(setting) = [2]> //Do this for all possibilities say [bye] end
Offline
Gravitation wrote:
It's easy; use a variable.
Create a variable named "setting". Put this script in your button:when gf clicked set [setting v] to [1] when [Sprite2] clicked change [setting v] by (1) set [setting v] to (((setting) mod (2)) + (1)) // Change the 2 to your amount of possibilities.Put this in Sprite1:when [Sprite1] clicked if <(setting) = [1]> say [hello] end if <(setting) = [2]> //Do this for all possibilities say [bye] end
i don't seem to have "when sprite2 clicked" were i can change the sprite. that control simply seem to want to use only the spirit which script i'm on, if that makes sense?
thank you anyways i do understand it all a little bit more, haha
Offline
arvidabystrom wrote:
Gravitation wrote:
It's easy; use a variable.
Create a variable named "setting". Put this script in your button:when gf clicked set [setting v] to [1] when [Sprite2] clicked change [setting v] by (1) set [setting v] to (((setting) mod (2)) + (1)) // Change the 2 to your amount of possibilities.Put this in Sprite1:when [Sprite1] clicked if <(setting) = [1]> say [hello] end if <(setting) = [2]> //Do this for all possibilities say [bye] endi don't seem to have "when sprite2 clicked" were i can change the sprite. that control simply seem to want to use only the spirit which script i'm on, if that makes sense?
thank you anyways i do understand it all a little bit more, haha
Right, the top two scripts that Gravitation gave you there would be found under a sprite called "sprite 2" - but it would be setting a variable that could be seen by all sprites, so sprite 1 scripts can make use of the results.
Offline
Paddle2See wrote:
arvidabystrom wrote:
Gravitation wrote:
It's easy; use a variable.
Create a variable named "setting". Put this script in your button:when gf clicked set [setting v] to [1] when [Sprite2] clicked change [setting v] by (1) set [setting v] to (((setting) mod (2)) + (1)) // Change the 2 to your amount of possibilities.Put this in Sprite1:when [Sprite1] clicked if <(setting) = [1]> say [hello] end if <(setting) = [2]> //Do this for all possibilities say [bye] endi don't seem to have "when sprite2 clicked" were i can change the sprite. that control simply seem to want to use only the spirit which script i'm on, if that makes sense?
thank you anyways i do understand it all a little bit more, hahaRight, the top two scripts that Gravitation gave you there would be found under a sprite called "sprite 2" - but it would be setting a variable that could be seen by all sprites, so sprite 1 scripts can make use of the results.
ok cool!
sorry for basically try to make people lead me through exactly step by step.
but the case now is that i made the sprite2 a button cuz it responds by changing the setting from 1 to 2. but when doing that i want sprite1's sound to change and that wont happen by some reason.
in sprite1 i have:
when space key pressed
if settings=1
forever if touching mouse-pointer
play sound (sound1)
if settings=2
forever if touching mouse-pointer
play sound (sound2)
and in sprite2:
when space key pressed
forever settings to 1
when sprite2 clicked
play sound (sound3)
forever
change settings by 2
set settings to settings mod 2 + 1
Offline
arvidabystrom wrote:
Paddle2See wrote:
arvidabystrom wrote:
i don't seem to have "when sprite2 clicked" were i can change the sprite. that control simply seem to want to use only the spirit which script i'm on, if that makes sense?
thank you anyways i do understand it all a little bit more, hahaRight, the top two scripts that Gravitation gave you there would be found under a sprite called "sprite 2" - but it would be setting a variable that could be seen by all sprites, so sprite 1 scripts can make use of the results.
ok cool!
sorry for basically try to make people lead me through exactly step by step.
but the case now is that i made the sprite2 a button cuz it responds by changing the setting from 1 to 2. but when doing that i want sprite1's sound to change and that wont happen by some reason.
in sprite1 i have:when key [space v] pressed if <(settings)=(1)> forever if (touching [mouse-pointer v]?) play sound [sound1 v] end end if <(settings)=(2)> forever if (touching [mouse-pointer v]?) play sound [sound2 v] endand in sprite2:when [space v] key pressed forever set [settings v] to (1) when [sprite2 v] clicked play sound [sound3 v] forever change [settings v] by (2) set [settings v] to ((settings) mod ((2) + (1)))
First of all, you have a forever block surrounding the [set settings to (1)] block in your second script, which is going to constantly set it to 1 once you press space. Try removing that. Also, you might want to change the [when space pressed] to [when gf clicked].
Moving on, your first script is going to always play sound1 the way you built it. To fix that, try replacing the forever if's with regular if's. Then, you might want to add this to the end of the script:
wait until <not (key [space v] pressed?)>I hope that this helps!
Offline
ErnieParke wrote:
arvidabystrom wrote:
Paddle2See wrote:
Right, the top two scripts that Gravitation gave you there would be found under a sprite called "sprite 2" - but it would be setting a variable that could be seen by all sprites, so sprite 1 scripts can make use of the results.ok cool!
sorry for basically try to make people lead me through exactly step by step.
but the case now is that i made the sprite2 a button cuz it responds by changing the setting from 1 to 2. but when doing that i want sprite1's sound to change and that wont happen by some reason.
in sprite1 i have:when key [space v] pressed if <(settings)=(1)> forever if (touching [mouse-pointer v]?) play sound [sound1 v] end end if <(settings)=(2)> forever if (touching [mouse-pointer v]?) play sound [sound2 v] endand in sprite2:when [space v] key pressed forever set [settings v] to (1) when [sprite2 v] clicked play sound [sound3 v] forever change [settings v] by (2) set [settings v] to ((settings) mod ((2) + (1)))First of all, you have a forever block surrounding the [set settings to (1)] block in your second script, which is going to constantly set it to 1 once you press space. Try removing that. Also, you might want to change the [when space pressed] to [when gf clicked].
Moving on, your first script is going to always play sound1 the way you built it. To fix that, try replacing the forever if's with regular if's. Then, you might want to add this to the end of the script:wait until <not (key [space v] pressed?)>I hope that this helps!
but when i don't have the forever if's when pressing the green flag and then putting my mouse-pointer over whatever was suppose to sound it simply doesn't sound? since one only have one mouse-pointer one can simply not press the green flag constantly and take the mouse-pointer and hold it over the object at the same time, so i don't really get why it works like that. geh
Offline
arvidabystrom wrote:
ErnieParke wrote:
arvidabystrom wrote:
ok cool!
sorry for basically try to make people lead me through exactly step by step.
but the case now is that i made the sprite2 a button cuz it responds by changing the setting from 1 to 2. but when doing that i want sprite1's sound to change and that wont happen by some reason.
in sprite1 i have:when key [space v] pressed if <(settings)=(1)> if (touching [mouse-pointer v]?) play sound [sound1 v] end end if <(settings)=(2)> if (touching [mouse-pointer v]?) play sound [sound2 v] end end wait until <not <key [space v] pressed?>>and in sprite2:when gf clicked set [settings v] to (1) when [sprite2 v] clicked play sound [sound3 v] change [settings v] by (2) set [settings v] to (((settings) mod (2)) + (1))First of all, you have a forever block surrounding the [set settings to (1)] block in your second script, which is going to constantly set it to 1 once you press space. Try removing that. Also, you might want to change the [when space pressed] to [when gf clicked].
Moving on, your first script is going to always play sound1 the way you built it. To fix that, try replacing the forever if's with regular if's. Then, you might want to add this to the end of the script:wait until <not (key [space v] pressed?)>I hope that this helps!but when i don't have the forever if's when pressing the green flag and then putting my mouse-pointer over whatever was suppose to sound it simply doesn't sound? since one only have one mouse-pointer one can simply not press the green flag constantly and take the mouse-pointer and hold it over the object at the same time, so i don't really get why it works like that. geh
He meant he wanted to replace the second 'when space key pressed' to 'when green flag clicked'.
Oh, and I just edited your scripts so it will work.
Offline
well i want sprite1 to start sound1 right away so that i either with the green flag or with the space key. so not only start it when pressed space.
and when i did it like you said the sound2 never goes off and sound1 is always sounding when mouse-pointer is over sprite1
Offline