This site requires JavaScript, please enable it in your browser!
Greenfoot back
Indy5Drew
Indy5Drew wrote ...

2018/1/30

HELP!!!!

Indy5Drew Indy5Drew

2018/1/30

#
I am attempting to build a piano where when you press one key on the keyboard, it plays a scale. my problem is that Idk how to make the second object sense that the first object has played, so that the notes are not all played at the same time, or not at all. is there a sensor method at all that would allow me to do that?
xbLank xbLank

2018/1/31

#
Maybe you want to uplaod your project
Super_Hippo Super_Hippo

2018/1/31

#
The objects shouldn't "sense" it. You could have your world control what sounds should be played one after another.
danpost danpost

2018/1/31

#
First, you need some kind of list to hold the key sequence (probably a character array, aka: a String object, would do nicely). Then, you need an int to track the progress of the playing of the sequence. When the sequence is to start, set the int field to the length of the sequence. This way, when the int field is zero, the sequence is not playing and when it is not, the sequence is playing. When the int field is greater than zero and either the field value equals the length of the sequence or the current note is not playing, (call a method to) play the note and decrease the int field (note played will be from the character at index equal to length of sequence minus int field value). Like Hippo said, this should be done in your World subclass.
You need to login to post a reply.