hi
i am trying to use a wait for inside a loop but i get an error.
i am doing it inside a Do...While loop. using sleep() does work but using a wait for() not.
am i doing something wrong or its not possible to do that like that?
relevant code:
error:
i am trying to use a wait for inside a loop but i get an error.
i am doing it inside a Do...While loop. using sleep() does work but using a wait for() not.
am i doing something wrong or its not possible to do that like that?
relevant code:
B4X:
'...
Wait For(drawsmoohtplayer) Complete (finished As Boolean)
If finished Then
If keepgoing Then
ismoving = True
trykeepgoing(direction)
End If
End If
'...
Sub drawsmoohtplayer As ResumableSub
Dim lastcell As cell = grid.Get(lastcellpos)
Dim cell As cell = grid.Get(myPlayer.pPos)
Dim difx As Float = (cell.left - lastcell.left) / 6
Dim dify As Float = (cell.top - lastcell.top) / 6
For i = 1 To 6 '6 frames
cONMAZE.ClearRect(cONMAZE.TargetRect)
Dim r As B4XRect
r.Initialize(lastcell.left+(w*0.22)+xCenter+(difx*i),lastcell.top+(w*0.22)+(dify*i),lastcell.right-(w*0.22)+xCenter+(difx*i),lastcell.bottom-(w*0.22)+(dify*i))
cONMAZE.DrawRect(r,xui.Color_White,True,0)
cONMAZE.Invalidate
Sleep(20)
Next
Return True
End Sub
error:
*** Service (starter) Create ***
** Service (starter) Start **
** Activity (main) Create, isFirst = true **
** Activity (main) Resume **
44 ms
levelmapsize: 100
1 ms
Error occurred on line: 319 (Main)
java.lang.reflect.InvocationTargetException
at java.lang.reflect.Method.invoke(Native Method)
at anywheresoftware.b4a.shell.Shell.runGoodChain(Shell.java:479)
at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:293)
at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:255)
at java.lang.reflect.Method.invoke(Native Method)
at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:144)
at anywheresoftware.b4a.BA$1.run(BA.java:335)
at android.os.Handler.handleCallback(Handler.java:873)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:214)
at android.app.ActivityThread.main(ActivityThread.java:7045)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:965)
Caused by: java.lang.NoSuchMethodError: No virtual method _move(Lwww/sagital/maze/madmaze;IZ)Ljava/lang/String; in class Lwww/sagital/maze/madmaze; or its super classes (declaration of 'www.sagital.maze.madmaze' appears in base.apk)
at www.sagital.maze.main._gamepnlin_touch(main.java:1370)
... 14 more
Error occurred on line: 319 (Main)
java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.Object java.lang.reflect.Method.invoke(java.lang.Object, java.lang.Object[])' on a null object reference
at anywheresoftware.b4a.shell.Shell.runGoodChain(Shell.java:479)
at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:293)
at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:255)
at java.lang.reflect.Method.invoke(Native Method)
at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:144)
at anywheresoftware.b4a.BA$1.run(BA.java:335)
at android.os.Handler.handleCallback(Handler.java:873)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:214)
at android.app.ActivityThread.main(ActivityThread.java:7045)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:965)
Error occurred on line: 319 (Main)
java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.Object java.lang.reflect.Method.invoke(java.lang.Object, java.lang.Object[])' on a null object reference
at anywheresoftware.b4a.shell.Shell.runGoodChain(Shell.java:479)
at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:293)
at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:255)
at java.lang.reflect.Method.invoke(Native Method)
at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:144)
at anywheresoftware.b4a.BA$1.run(BA.java:335)
at android.os.Handler.handleCallback(Handler.java:873)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:214)
at android.app.ActivityThread.main(ActivityThread.java:7045)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:965)
** Activity (main) Pause, UserClosed = true **