I made a little game for pigs to play
moving a ball on the screen "mani"pulating
a joystick with their snout.
The thing is that I would like a sound to be triggered
when the ball symbol is moving, so that the pig will registre
an audible responce.
Im using a script for the joystick movement
from www.bigredswitch.co.uk - and would like a solution
wich operates from the _x _y pos of the ball obj,
rather than the joystic input.
Mainly because I can't see how the latter should be done.
If your object is a movie clip. You can just check the x and y properties of the ball. Put them in a variable. When the variable changes play the sound, otherwise don't.
I just got a mail from karsten and svineline (not as previous mentioned griseline).
She is doing fine - on the third day she discovered the connection between screen and the joystick. Advanced to level 3, where she scored 7 games in row.
Originally posted by Hans Jacob It works nice with the joystick.
the only thing I really need to solve now, is the timing of the sound.
I get to many "playsound" objects running at the same time.
like 60 a sec. And it dosn't sound nice, but you know you've been moving the joystick.
I'll fumble around with "set interval" and see if I can get that to work.
Nice that you got it working.
I didn't actualy realize that it would be real pigs playing the game! That's great. I love pigs.
I've been trying to work on some solutions but I can't figure it out at the moment. The direction you should be looking might be:
1) Do something with test_sound.onSoundComplete = function(){
// do something only when the previous sound has stopped
};
2) make the if (_root.ball._x != xpos) less sensitive, for example only when it's _root.ball._x + 5
Hope you can work it out. I couldn't. You can also post sound questions on the sound board here. Or check out this tutorial: http://www.kennybellew.com/
Originally posted by Hans Jacob I think that the != inequallity will only be more stressed
if you add +5 - it will then never stop playing - I think!?
You'll have to play with it. Something like if (_root.ball._x == xpos + 5) This triggers the action only when there has been a 5 pixels movement. That's my idea.
I tryed that in a numerous ways
and I can't figure out how to make it == xpos +/- 5
because the movement can be either decreasing or increasing
and should'nt it be <== xpos+5 or ==> xpos-5
are you able to make such if,or,then else statements
also if you got an if / else statement
what would the if command be ? "ignore", how do you put that?
because if the above statement is true it should just continue.
I messing around alot, and don't know if my actions are legaly entered
thanks again for your help.
I tryed to use the setinterval to pause different parts of the script functions, but with out any luck.
the >= xpos +5 works in the on direction,
when the joystick is pulled right the statement comes true after a short pace, but after that it stays true, until its released.
It brings me back to the original problem.
instead of going dack.. dack.. dack ... it goes
drellllllllllllllllllllllllllllllllll...
I will have to figure it out in another way
running short on ideas
I think I worked it out. Please look here and let me know if it helps. You'll have to adjust the code for the y coordinates yourself. http://www.numuseum.com/diversen/sound2.zip