让小车红灯停,绿灯行出现以下情况不能解决:
8 x2 a. t: V6 a, R1)is
$ E+ e8 u0 c3 `5 Cdo
7 V! r3 |+ W9 S2 g$ S if light="green"
+ Z0 `) A- }% x" ] A; E5 _/ L then @.stopped:=false;
+ V& ~# F6 F) W& o else1 z% ~2 B+ C0 t
@.stopped:=true;
! ], o& ^0 p4 V' W# h6 `' }6 l end;$ n( M; c( A# M) s2 p
end;
; a7 K' R s# W( O7 l4 }. U; K) c' j
$ c# |& i' k& E, H5 J用if else then,只会停止,不能运动,停了以后Method 不会再被调;: A }: @3 J9 P' V; A m. E# ^" V
2)is+ E% _/ b5 ~. B, W# j: _
do
* O: `' n# a9 d if light="green"8 E% v P6 j% c7 p- x2 w/ P, Z4 }
then @.stopped:=false;# `- P* n* C# c) J
else
: a1 [4 m8 V1 C4 J# e( i! E @.stopped:=true;
5 {# Q+ S& |0 K- T end;. o2 ]7 @! F; t2 s# d
@.move;--加了这个以后则不管红绿灯都是一直运动的,* J' |6 P7 k* U+ }( |) T. g
end;; U0 ^2 x- i7 h
3)用ispect-when-when-else,出现同样的情况" q, x+ {3 Y g3 [$ n- h* V
求高手解决。 |