让小车红灯停,绿灯行出现以下情况不能解决:! c u f2 {# I2 M$ e3 j0 |
1)is9 r1 S- K# H0 D2 e1 W$ b
do
5 ^' l/ [4 a3 ^: e+ a8 h4 R if light="green": @+ y& D. ?4 |: @- Y
then @.stopped:=false;; k& g3 H9 `& D0 F0 T
else2 r& g' m7 S" M& Z2 R, @
@.stopped:=true;
; q8 M: B1 @* t! G end;+ |: ~! m' M# k
end;
: R8 h# W; T: X
# R) L- V" `4 N% w1 H' I用if else then,只会停止,不能运动,停了以后Method 不会再被调;& N' R( g: |, m7 F# P0 i" _8 d
2)is
( r; A$ L: \7 udo
c0 J0 _$ o! k: q if light="green"
- ?% G1 [+ G# j2 v then @.stopped:=false;
( r: q3 g' @' R7 g; t else
+ x& p, [& W2 b1 @, D: p1 h @.stopped:=true;/ R( m- Y. u- B( }9 I1 M# G# ]# e
end;
- l; W8 M+ v5 ]. `) b9 h$ y' c@.move;--加了这个以后则不管红绿灯都是一直运动的,2 V/ Y. H a4 u+ S$ g
end;
, O0 {2 Z) m; Z1 s. |( X3)用ispect-when-when-else,出现同样的情况
9 W5 d; r M& C* j3 x7 P求高手解决。 |