i am trying to implement am arrow shoot in my game bt getting an error.
this is what i want to archive (http://www.iforce2d.net/b2dtut/sticky-projectiles)
i have this:
i dont know how to implement the b2Dot method in b4a.
i have no (vec2,vec2) option i have only a 1 vec2 option.
i think it is a box2d function but in box2d for b4a there is no n2dot method.
the error i am getting is this:
i am sure i have not converted the code correctly but i am not sure how to do that. who can help me please?
thank you
this is what i want to archive (http://www.iforce2d.net/b2dtut/sticky-projectiles)
i have this:
B4X:
'create arrow
Dim chez As lgBox2DPolygonShape
Dim vertex(4) As lgMathVector2
vertex(0).Set(-1.4,0)
vertex(1).Set(0,-0.1)
vertex(2).Set(0.6,0)
vertex(3).Set(0,0.1)
chez.Set(vertex)
'create body
Dim fd As lgBox2DFixtureDef
fd.shape = chez
fd.restitution = 0.2
fd.Density = 1
fd.friction = 0.5
Dim bd_def As lgBox2DBodyDef
bd_def.type = World.BODYTYPE_Dynamic
bd_def.position.set(PosCon.world2box2d(ScreenX,ScreenY,0,0).x,PosCon.world2box2d(ScreenX,ScreenY,0,0).y)
Dim box2dbody As lgBox2DBody
box2dbody = World.createBody(bd_def)
box2dbody.createFixture(fd)
chez.dispose
Dim pointingDirection As lgMathVector2
pointingDirection.Set(ScreenX,ScreenY)
Dim flightDirection As lgMathVector2 = box2dbody.getLinearVelocityFromWorldPoint(box2dbody.WorldCenter)
Dim flightSpeed As Float = flightDirection.nor '();//normalizes And returns length
Dim lmath As lgMathVector2
Dim dot As Float = lmath.dot(pointingDirection)
Dim dragForceMagnitude As Float = (1 - Abs(dot)) * flightSpeed * flightSpeed * 1 * box2dbody.Mass
Dim vec2 As lgMathVector2
vec2.Set(-1.4,0)
Dim arrowTailPosition As lgMathVector2 = box2dbody.getWorldPoint(vec2)
Dim vec3 As lgMathVector2
vec3.Set(dragForceMagnitude*(-flightDirection.x),dragForceMagnitude*(-flightDirection.y))
box2dbody.applyForce(vec3, arrowTailPosition,True)
i dont know how to implement the b2Dot method in b4a.
i have no (vec2,vec2) option i have only a 1 vec2 option.
i think it is a box2d function but in box2d for b4a there is no n2dot method.
the error i am getting is this:
** Activity (main) Create, isFirst = true **
** Activity (main) Resume **
sensor listener setup
OGL renderer: Android Emulator OpenGL ES Translator (Intel(R) HD Graphics 4000)
OGL vendor: Google (Intel)
OGL version: OpenGL ES 2.0 (4.0.0 - Build 10.18.10.4358)
OGL extensions: GL_EXT_debug_marker GL_OES_EGL_image GL_OES_EGL_image_external GL_OES_depth24 GL_OES_depth32 GL_OES_element_index_uint GL_OES_texture_float GL_OES_texture_float_linear GL_OES_compressed_paletted_texture GL_OES_compressed_ETC1_RGB8_texture GL_OES_depth_texture GL_OES_texture_half_float GL_OES_texture_half_float_linear GL_OES_packed_depth_stencil GL_OES_vertex_half_float GL_OES_texture_npot GL_OES_rgb8_rgba8ANDROID_EMU_CHECKSUM_HELPER_v1
framebuffer: (5, 6, 5, 0)
depthbuffer: (16)
stencilbuffer: (0)
samples: (0)
coverage sampling: (false)
Managed meshes/app: { }
Managed textures/app: { }
Managed shaders/app: { }
Managed buffers/app: { }
main_ip_touchdown (java line: 799)
java.lang.NumberFormatException: For input string: "[0.0:0.0]"
at java.lang.FloatingDecimal.readJavaFormatString(FloatingDecimal.java:1306)
at java.lang.Double.parseDouble(Double.java:547)
at anywheresoftware.b4a.BA.ObjectToNumber(BA.java:646)
at www.sagital.tmi.main._ip_touchdown(main.java:799)
at java.lang.reflect.Method.invoke(Native Method)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:186)
at anywheresoftware.b4a.libgdx.input.lgInputProcessor$1.touchDown(SourceFile:81)
at com.badlogic.gdx.InputMultiplexer.touchDown(SourceFile:93)
at com.badlogic.gdx.backends.android.AndroidInput.a(SourceFile:387)
at com.badlogic.gdx.backends.android.AndroidGraphics.onDrawFrame(SourceFile:448)
at android.opengl.GLSurfaceView$GLThread.guardedRun(GLSurfaceView.java:1553)
at android.opengl.GLSurfaceView$GLThread.run(GLSurfaceView.java:1253)
java.lang.NumberFormatException: For input string: "[0.0:0.0]"
java.lang.RuntimeException: Can't create handler inside thread that has not called Looper.prepare()
at android.os.Handler.<init>(Handler.java:200)
at android.os.Handler.<init>(Handler.java:114)
at android.app.Dialog.<init>(Dialog.java:121)
at android.app.AlertDialog.<init>(AlertDialog.java:200)
at android.app.AlertDialog$Builder.create(AlertDialog.java:1086)
at anywheresoftware.b4a.BA.ShowErrorMsgbox(BA.java:260)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:224)
at anywheresoftware.b4a.libgdx.input.lgInputProcessor$1.touchDown(SourceFile:81)
at com.badlogic.gdx.InputMultiplexer.touchDown(SourceFile:93)
at com.badlogic.gdx.backends.android.AndroidInput.a(SourceFile:387)
at com.badlogic.gdx.backends.android.AndroidGraphics.onDrawFrame(SourceFile:448)
at android.opengl.GLSurfaceView$GLThread.guardedRun(GLSurfaceView.java:1553)
at android.opengl.GLSurfaceView$GLThread.run(GLSurfaceView.java:1253)
** Activity (main) Pause, UserClosed = true **
waiting for pause synchronization took too long; assuming deadlock and killing
i am sure i have not converted the code correctly but i am not sure how to do that. who can help me please?
thank you