Hallo,
habe ein kleines Breakout Spiel geschrieben und hänge jetzt an zwei Dingen fest.
1. Wenn im laufenden Spiel eine bestimmte Bedingung erfüllt wird soll ein graphic Objekt von oben nach unten durch das Spielfeld fallen.
Hier der Code:
if the label of btn i is "orange" then ##Wenn ein oranger Stein getroffen wurde
unlock screen
send mouseUp to graphic "Oval"
add 15 to the last word of field "Score"
set the loc of fld "PointsOrange" to the loc of btn i
set the visible of fld "PointsOrange" to true
end if
Das funktioniert aber nicht so richtig. Dh. das graphic Objekt fällt zwar nach unten, aber wärend es fällt stoppt der die Kugel und bewegt sich erst wieder, wenn die Anweisung im graphic Objekt fertig ausgeführt wurde.
Ich möchte aber, dass die Kugel sich weiter bewegt und Spielbar bleibt.
Hier der Code aus dem graphic Objekt:
on mouseUp
/* hid ethe cursor whilst the ball drops*/
set cursor to none
put the loc of me into myLocation
/* drop the ball */
move me to (item 1 of myLocation,572) in 40 ticks
/*hang about for a second ... in the bottom of the bucket*/
##wait 1 sec
/* restore the ball to the start location*/
##move me to (item 1 of myLocation,48) in 30 ticks
end mouseUp
on mouseUp
...
move me to (item 1 of myLocation,572) in 40 ticks WITHOUT WAITING
...
end mouseUp
Was habt ihr eigentlich alle gegen das Dictionary, was mit einem Klick so viel Licht in euer Dunkel bringen könnte? Das war ein rein rhetorische Frage! 8-)
Noch ein paar Tips:
## Ein Gleicheitszeichen ist wesentlich schneller und besser erkennbar
## in einem langen Text/Skript, daher verwende ich das immer anstatt IS
## if the label of btn i is "orange" then
if the label of btn i = "orange" then
unlock screen
## Messages bei SEND IMMER in Anführungszeichen
send "mouseUp" to grc "Oval"
## Optional, aber weniger zu schreiben :-)
## add 15 to the last word of field "Score"
add 15 to word -1 of fld "Score"
set the loc of fld "PointsOrange" to the loc of btn i
set the visible of fld "PointsOrange" to true
end if
Ich weiß, ich nerve, aber irgendwann wird sich das auszahlen, denn mit jeder Version wird die Engine weniger nachsichtig mit "salopper" Programmierung.
Glaubt mir, ich arbeite seit 20 Jahren mit LC und seinen Vorfahren!
on mouseUp
// hid ethe cursor whilst the ball drops*/
set cursor to none
put the loc of me into myLocation
// drop the ball */
move me to (item 1 of myLocation,572) in 40 ticks WITHOUT WAITING
//hang about for a second ... in the bottom of the bucket*/
wait 1 millisecond
// restore the ball to the start location*/
// move me to (item 1 of myLocation,48) in 30 ticks WITHOUT WAITING
set the loc of me to myLocation
end mouseUp
Ergebnis ist, dass das graphic Object sich zwar nach unten bewegt (die Kugel bleibt jetzt weiter in Bewegung), aber das graphic Object kehrt nicht zum Startpunkt zurück.
1. Frage ?
Ich habe in der IDE ein ovales gaphic Object in meine Karte gezogen und es Coins100 genannt.
2. Frage
move me to (item 1 of myLocation,48) in 30 ticks WITHOUT WAITING
natürlich nicht auskommentiert.
Aber wenn ich mit wait 1 millisecond arbeite,
kehrt das graphicObject "Coins100" nicht zurück
wenn ich mit wait 1 Second arbeite
kehrt das Icon zurück aber nur wenn ich es anklicke
über den send "mouseUp" Befehl tut sich dann aber gar nichts mehr.
ich denke weil ich dieses WITHOUT WAITING mit wait 1 Second ja wieder negiere.
Ganz schön verzwickt.