1. Bodies are only destroyed automatically if:
- You checked the 'destroy if invisible' option.
- Or based on the 'time to live' value if it is larger than 0.
1. The structure of the zip file is not the best structure. You should organize the folders as in the examples if you want to create a cross platform solution.
2. The issue with the alignment happens because the default 'angle interval' is 5. You can change it in Tiled.
2, if i resize the window the touched x,y mouse position change so it looks like the X2.ScreenAABB.Height is not updated if i resize my form. is there a different value i can from x2 that is updated if the form is resized? i need to create a ball on the touched mouse x/y position.
It is checked:as far as i remember the 'destroy if invisible' option is unchecked and i also see that the bodies are destroied once they are outside the frame and not afte x ticks. so i am not sure if it is a coding mistake by me or a bug in reading the object properties. i dont have tiled installed in my work so i cannot open the file but you can check it.
Not exactly.ok i understand so each tick the image is updated and i can set the angle update value.
The ScreenAABB doesn't change when you resize the window. The screen pixels to meter ratio changes.2, if i resize the window the touched x,y mouse position change so it looks like the X2.ScreenAABB.Height is not updated if i resize my form. is there a different value i can from x2 that is updated if the form is resized? i need to create a ball on the touched mouse x/y position.
Private Sub PanelForTouch_Touch (Action As Int, X As Float, Y As Float)
If Action = PanelForTouch.TOUCH_ACTION_DOWN Then
Dim template As X2TileObjectTemplate = TileMap.GetObjectTemplateByName(ObjectLayer, "circle")
template.BodyDef.Position = X2.ScreenPointToWorld(X, Y)
TileMap.CreateObject(template)
End If
End Sub
#CustomBuildAction: folders ready, %WINDIR%\System32\Robocopy.exe,"..\..\Shared Files" "..\Files"
Now we no longer need to worry about outdated files in different platforms
for i = 0 to tileobjectlist.size -1
dim obj as tiledobject = tileobjectlist.get(i)
if obj.shape = "ellipse" then ...
next
Dim ol As X2ObjectsLayer = TileMap.Layers.Get(ObjectLayer)
For Each template As X2TileObjectTemplate In ol.ObjectsById.Values
Select template.Name
Case "circle", "hinge"
'do nothing
Case "ground"
Dim bw As X2BodyWrapper = TileMap.CreateObject(template)
bw.Body.GravityScale = 0 'do something special with the ground bodies.
Case Else
TileMap.CreateObject(template)
End Select
Next
Dim ol As X2ObjectsLayer = TileMap.Layers.Get(ObjectLayer)
For Each template As X2TileObjectTemplate In ol.ObjectsById.Values
If template.FixtureDef.Shape Is B2CircleShape Then
TileMap.CreateObject(template)
End If
Next
Note that there is no ellipse shape in box2d or XUI2D. Tiled ellipses are converted to circles.
Dim Sw As SwitchData = Switch.Tag
Sw.State = Not(Sw.State)
If Sw.State Then
Switch.CurrentFrame = 1
Else
Switch.CurrentFrame = 0
End If
Sub TouchedSwitch(x As Float, y As Float) As X2BodyWrapper
Dim aabb As B2AABB
Dim vec As B2Vec2 = X2.ScreenPointToWorld(x, y)
aabb.Initialize2(vec, vec)
For Each body As B2Body In world.QueryAABBToMapOfBodies(aabb).Keys
If body.FirstFixture.Shape.TestPoint(body.Transform, vec) Then
Dim bw As X2BodyWrapper = body.Tag
If bw.Tag Is SwitchData Then
Return bw
End If
End If
Next
Return Null
End Sub
Public const MAX_SIZE_FOR_ANTIALIAS As Int = 300 'change to 800
If 'switch frame interval' is set to 0 then the graphics will not change automatically.
This will allow you to manually change the current frame:
4. Your code for finding the touched body is not very efficient. Especially if there will be many bodies. A more efficient solution based on box2d internal tree of AABBs:
7. The usage of tags is fine. However it would not have been required if you used a class for the balls and the switches. It is up to you.
They are included in the project I've uploaded.about the fixed x2 classes, do i need to update them ? or they are still not available ? (crash fixes,...)
I can add this code to X2Utils.ok i understand, in spritekit it is very simple to get a body from a point. you can ask to get a list of all bodies that collide with your touched point and like this you can work with those bodies.
Private Sub PanelForTouch_Touch (Action As Int, X As Float, Y As Float)
If Action = PanelForTouch.TOUCH_ACTION_DOWN Then
Dim worldpoint As B2Vec2 = X2.ScreenPointToWorld(X, Y)
For Each TouchedBody As X2BodyWrapper In X2.GetBodiesIntersectingWithWorldPoint(worldpoint)
If TouchedBody.Tag Is SwitchData Then
Log("YOU TOUCHED A SWITCH")
Dim Sw As SwitchData = TouchedBody.Tag
Sw.State = Not(Sw.State)
If Sw.State Then
TouchedBody.CurrentFrame = 1
Else
TouchedBody.CurrentFrame = 0
End If
Return
End If
Next
Dim template As X2TileObjectTemplate = TileMap.GetObjectTemplateByName(ObjectLayer, "ball")
template.BodyDef.Position = worldpoint
CreateBall(template)
End If
End Sub
It is explained in section 4.5: http://box2d.org/manual.pdfjust have a curiosity: what AABB is?
XUI2D API is mostly identical to box2d API.it seemed strange to me that AnywhereSoftware had used a so very cryptic name
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?