Games xui2d.jar

erol34

Member
Licensed User
Hi,

There are xui2d.jar and x2.b4xlib files in library folder of B4J (or B4A) x2.b4xlib is X2 framework and it uses xui2d.jar I think ? (although can not see any reference in X2 source files)
I see a method called setTangentSpeed for b2contact class in a jbox2d page.. It is used for conveyor or tank palet movements. But X2 has no such method for Contact.. How can I use this method ? I can see it when I open xui2d.jar and look into class files with Notepad++.
 

Erel

B4X founder
Staff member
Licensed User
Longtime User
There are xui2d.jar and x2.b4xlib files in library folder of B4J (or B4A) x2.b4xlib is X2 framework and it uses xui2d.jar I think ?
Yes (the B4A and B4J versions).

I can see it when I open xui2d.jar and look into class files with Notepad++.
Source code is available here: https://github.com/AnywhereSoftware/B4J/tree/master/Libs_XUI2D/src

The relevant java code:
B4X:
@ShortName("B2Contact")
public class B2Contact {
    @Hide
    public Contact contact;

This means that you can access the native contact with:
B4X:
Dim TangnetSpeed As Float = 12
'contact is the B2Contact object
contact.As(JavaObject).GetFieldJO("contact").RunMethod("setTangentSpeed", Array(TangnetCode)
 

erol34

Member
Licensed User
Thank you so much @Erel. I tried and it works.. May be someone else wants to try this method, I add 2 subs to Tank Attack sample program.. And tank starts to move without pressing any keys, ground behaves like a conveyor.. Tank's brake system is broken possibly :) PreSolve and BeginContact occurs when there is a collision, then you can manipulate the results of collision in PreSolve. Tank palet and ground are in collision. PreSolve sub is not trigerred without BeginContact sub..
B4X:
Sub World_PreSolve (Contact As B2Contact, OldManifold As B2Manifold)
    Dim bc As X2BodiesFromContact = X2.GetBodiesFromContact(Contact, "tank")
    Dim TangentSpeed As Float = 5
    If bc <> Null And bc.OtherBody.Name.StartsWith("ground") Then
        'Contact.IsEnabled = False 
        Contact.As(JavaObject).GetFieldJO("contact").RunMethod("setTangentSpeed",Array(TangentSpeed))
    End If
End Sub

Sub World_BeginContact (Contact As B2Contact)

End Sub
 
Top