-
-
Notifications
You must be signed in to change notification settings - Fork 2
/
README.bbcode
646 lines (444 loc) · 24.4 KB
/
README.bbcode
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
[b][size=14pt]agsbox2d[/size][/b] [color=gray][b] version 0.5.0 [/b][/color]
[url=https://github.com/ericoporto/agsbox2d/releases/download/0.5.0/agsbox2d.dll]Get Latest Release [b]agsbox2d.dll[/b][/url] | [url=https://github.com/ericoporto/agsbox2d/releases/download/0.5.0/libagsbox2d.so][b]libagsbox2d.so[/b][/url] | [url=https://github.com/ericoporto/agsbox2d/releases/download/0.5.0/libagsbox2d.dylib][b]libagsbox2d.dylib[/b][/url] | [url=https://github.com/ericoporto/agsbox2d]GitHub Repo[/url] | [b][url=https://github.com/ericoporto/agsbox2d/releases/download/0.5.0/agsbox2d_demo_windows.zip]Demo Windows[/url][/b] | [b][url=https://github.com/ericoporto/agsbox2d/releases/download/0.5.0/agsbox2d_demo_linux.tar.xz]Demo Linux[/url][/b]
[url=https://dev.azure.com/ericoporto/agsbox2d/_build/latest?definitionId=11&branchName=master][img]https://dev.azure.com/ericoporto/agsbox2d/_apis/build/status/ericoporto.agsbox2d?branchName=master[/img][/url]
AgsBox2D is a physics plugin for Adventure Game Studio that gives access to the Box2D library created by Erin Catto.
Because I never used Box2D directly before, I tried to make the API similar to Love physics module.
[img]https://raw.githubusercontent.com/ericoporto/agsbox2d/master/agsbox2d_demo.gif[/img]
AgsBox2D is still in early development.
[b][size=12pt]In development warning[/size][/b]
AgsBox2D is in development. Still, if you want to experiment with it and report your findings, this post should prove itself useful and I appreciate any help in making this plugin work well with AGS.
[b][size=12pt]Usage example[/size][/b]
Below we will do a very simple example that creates a ground, and adds a box and a ball. The ball is controlled by keyboard input. The game is supposed 320x200 in this example.
[code=ags]// room script file
World* world;
Overlay* ov;
struct Physical {
Body* body;
Shape* shape;
Fixture* fixture;
};
Physical ground;
Physical ball;
function room_Load()
{
if(world == null){
AgsBox2D.SetMeter(32.0);
world = AgsBox2D.CreateWorld(0.0, 9.8*AgsBox2D.GetMeter());
ground.body = AgsBox2D.CreateBody(world, 160.0, 160.0, eBodyStatic);
ground.shape = AgsBox2D.CreateRectangleShape(320.0, 40.0);
ground.fixture = AgsBox2D.CreateFixture(ground.body, ground.shape);
ball.body = AgsBox2D.CreateBody(world, 160.0, 40.0, eBodyDynamic);
ball.shape = AgsBox2D.CreateCircleShape(20.0);
ball.fixture = AgsBox2D.CreateFixture(ball.body, ball.shape, 1.0);
ball.fixture.Restitution = 0.5;
AgsBox2D.CreateFixture(AgsBox2D.CreateBody(world, 80.0, 60.0, eBodyDynamic),
AgsBox2D.CreateRectangleShape(30.0, 20.0), 5.0);
}
}
function room_RepExec()
{
if(IsKeyPressed(eKeyLeftArrow)) ball.body.ApplyForce(-500.0, 0.0);
if(IsKeyPressed(eKeyRightArrow)) ball.body.ApplyForce(500.0, 0.0);
if(IsKeyPressed(eKeyUpArrow) && ball.body.IsTouching(ground.body)){
ball.body.ApplyForce(0.0, -6000.0);
ball.body.SetLinearVelocity(0.0, 0.0);
}
if(ov!=null && ov.Valid) ov.Remove();
ov = Overlay.CreateGraphical(0, 0, world.GetDebugSprite(), true);
world.Step(1.0/IntToFloat(GetGameSpeed()), 8, 3);
}[/code]
There's a [url=https://www.adventuregamestudio.co.uk/forums/index.php?topic=57458.msg636613531#msg636613531]breakdown of this code here[/url].
[b][size=12pt]Script API[/size][/b]
[spoiler][i][b]AgsBox2D[/b][/i]
[list]
[li][b][tt]void AgsBox2D.SetMeter(float meter)[/tt][/b]
Sets how many pixels equals to a meter. Default is 32 pixels per meter.
[b][i]Do this only once, before using any other functions, it doesn't apply retroactively[/i][/b]
You want the size of your moving objects roughly between 0.1 and 10 meters.
For the default 32px this enables objects between 3 and 320 pixels, so this usually needs to scale along with your game resolution and character size.
Internally, Box2D uses Meter, Kilograms and Seconds as it's main units.
[/li]
[li][b][tt]float AgsBox2D.GetMeter()[/tt][/b]
Get's previously passed meter in pixels.
[/li]
[li][b][tt]World* AgsBox2D.CreateWorld(float gravityX, float gravityY)[/tt][/b]
Creates a World object, this should be done before creating bodies.
A positive gravityY is directed to ground, and a negative gravityY is directed upwards.
Similarly, a positive gravityX is directed to right and a negative gravityX is directed to left.
[/li]
[li][b][tt]Body* AgsBox2D.CreateBody(World* world, float x, float y, BodyType bodytype)[/tt][/b]
Creates a body object in the world, at specified x and y positions.
These positions correspond to the center of the body.
The bodytype can be any of the types below:
- [tt]eBodyStatic[/tt] : An object that does not move under simulation, usually the
ground in a platformer is a static body. It doesn't collide with other static
or kinematic bodies. A static body has zero velocity.
- [tt]eBodyDynamic[/tt] : A fully simulated body, can collide with all body type,
this body moves according to forces. It always has finite non-zero mass.
- [tt]eBodyKinematic[/tt] : A kinematic body moves according it's velocity, it doesn't
move according to forces. A Kinematic body behaves as if it has infinite mass.
It doesn't collide with other Kinematic bodies or with static bodies.
Any bodytype can be moved by user input, but you have to specific code the behavior in AGS.
You don't need to keep the returned pointer if you aren't going to need to access this body anymore, since the world will hold it, but you will be unable to destroy it unless the world is destroyed.
The specifics on a body form and mass are defined by using a Shape and Fixture.
[/li]
[li][b][tt]void AgsBox2D.DestroyBody(World* world, Body* body)[/tt][/b]
Removes a body from the world, and marks it with the property IsDestroyed true.
[/li]
[li][b][tt]Shape* AgsBox2D.CreateRectangleShape(float w, float h, float x=0, float y=0)[/tt][/b]
Creates a RectangleShape with Width w and Height h, and returns a Shape object.
You can also change it's relative center which will be mapped to the body center.
An x of 0.0 and y of 0.0, which are defaults, maps to the shape center.
[/li]
[li][b][tt]Shape* AgsBox2D.CreateCircleShape(float radius, float x=0, float y=0)[/tt][/b]
Creates a Circle shape, and similar to RectangleShape, you can also translate it's center.
[/li]
[li][b][tt]Fixture* AgsBox2D.CreateFixture(Body* body, Shape* shape, float density=0)[/tt][/b]
Creates a Fixture, and attachs a body a shape, and specifies a density.
You should always pass finite non-zero densities for dynamic bodies.
You don't need to keep the pointer to the shape attached to a body through a fixture, since the body will hold a copy of the shape.
Similarly, you also don't need to keep a pointer to the fixture, because the body will hold it too.
[/li]
[li][b][tt]Joint* AgsBox2D.CreateDistanceJoint(Body* bodyA, Body* bodyB, float a_x, float a_y, float b_x, float b_y, bool collideConnected = 0)[/tt][/b]
Create Distance Joint, pass anchors on bodies A and B using world coordinates. The two bodies are assumed to be in place when this joint is created.
This joint constrains the distance between two points on two bodies to be constant. The first anchor point is connected to the first body and the second to the second body, and the points define the length of the distance joint.
[/li]
[li][b][tt]Joint* AgsBox2D.CreateMotorJoint(Body* bodyA, Body* bodyB, float correction_factor, bool collideConnected = 0)[/tt][/b]
Create Motor Joint. This is a joint between two bodies which controls the relative motion between them.
Position and rotation offsets can be specified once the MotorJoint has been created, as well as the maximum motor force and torque that will be be applied to reach the target offsets.
[/li]
[li][b][tt]Joint* AgsBox2D.CreateMouseJoint(Body* bodyA, float x, float y)[/tt][/b]
Create Mouse Joint between body and a target point in the world. To make it follow the mouse, the fixed point must be updated every time-step.
The advantage of using a MouseJoint instead of just changing a body position directly is that collisions and reactions to other joints are handled by the physics engine.
[/li]
[li][b][tt]Joint* AgsBox2D.CreatePulleyJoint(Body* bodyA, Body* bodyB, PointF* groundAnchorA, PointF* groundAnchorB, PointF* localAnchorA, PointF* localAnchorB, float ratio, bool collideConnected = 0)[/tt][/b]
Creates a PulleyJoint to join two bodies to each other and the ground.
The pulley joint simulates a pulley with an optional block and tackle. If the ratio parameter has a value different from one, then the simulated rope extends faster on one side than the other. In a pulley joint the total length of the simulated rope is the constant length1 + ratio * length2, which is set when the pulley joint is created.
Pulley joints can behave unpredictably if one side is fully extended. It is recommended that the method setMaxLengths be used to constrain the maximum lengths each side can attain.
[/li]
[li][b][tt]void AgsBox2D.DestroyJoint(World* world, Joint* body)[/tt][/b]
Removes a joint from the world, it should no longer return true to isValid.
[/li]
[/list]
[i][b]PointF[/b][/i]
[list]
[li][b][tt]PointF* PointF.Create(float x, float y)[/tt][/b]
Creates a PointF object with x and y values.
[/li]
[li][b][tt]float PointF.X[/tt][/b]
The X coordinate property of a PointF.
[/li]
[li][b][tt]float PointF.Y[/tt][/b]
The Y coordinate property of a PointF.
[/li]
[li][b][tt]float PointF.Length()[/tt][/b]
Returns distance from point (X,Y) coordinates to origin (0,0).
[/li]
[li][b][tt]float PointF.SquaredLength()[/tt][/b]
Returns squared distance from point (X,Y) coordinates to origin (0,0). Slightly faster than Length.
[/li]
[li][b][tt]PointF* PointF.Add(PointF* pointF)[/tt][/b]
Returns a new point with the sum of this with pointF.
[/li]
[li][b][tt]PointF* PointF.Sub(PointF* pointF)[/tt][/b]
Returns a new point with the subtraction of pointF from this.
[/li]
[li][b][tt]PointF* PointF.Scale(float scale)[/tt][/b]
Returns a new point that is a copy of this point multiplied by a scalar.
[/li]
[li][b][tt]PointF* PointF.Rotate(float angle, float pivot_x = 0, float pivot_y = 0)[/tt][/b]
Returns a new point with this point treated as a vector to a pivot point, rotated by an angle in radians. If you don't specify, pivot is origin (0,0).
[/li]
[li][b][tt]Point* PointF.ToPoint()[/tt][/b]
Rounds this point as integer and returns a standard AGS Point object.
[/li]
[/list]
[i][b]Body[/b][/i]
[list]
[li][b][tt]int Body.X[/tt][/b]
The X position property of a body as integer.
Avoid setting this property directly. Bodies coordinates are actually float values in the simulation, this is provided as convenience.
[/li]
[li][b][tt]int Body.Y[/tt][/b]
The Y position property of a body as integer.
Avoid setting this property directly. Bodies coordinates are actually float values in the simulation, this is provided as convenience.
[/li]
[li][b][tt]float Body.fX[/tt][/b]
The X position property of a body as float.
[/li]
[li][b][tt]float Body.fY[/tt][/b]
The Y position property of a body as float.
[/li]
[li][b][tt]float Body.Angle[/tt][/b]
The Body Angle property. AGS can't easily rotate Sprites so avoid using angles with bodies that you expect to map directly in someway to screen sprites.
[/li]
[li][b][tt]bool Body.FixedRotation[/tt][/b]
By default, bodies are created with FixedRotation set to true.
A body with FixedRotation set to true does not rotate, causing it's rotational inertia and it's inverse to be set to zero.
[/li]
[li][b][tt]bool Body.Bullet[/tt][/b]
By default, bodies are created with Bullet set to false.
Set bullet to true when the body has a small shape and moves really fast, this will prevent the body from having wrong collisions with thin bodies.
[/li]
[li][b][tt]readonly bool Body.IsDestroyed[/tt][/b]
Returns true if it's destroyed by [tt]AgsBox2D.DestroyBody()[/tt].
[/li]
[li][b][tt]float Body.LinearDamping[/tt][/b]
The LinearDamping property of a body. Damping occurs independently from contact and is different than friction.
Normally the value for damping is between [tt]0.0[/tt] and [tt]0.1[/tt].
[/li]
[li][b][tt]float Body.AngularDamping[/tt][/b]
The AngularDamping property of a body, the angular drag, also happens
independently from contact.
[/li]
[li][b][tt]float Body.AngularVelocity[/tt][/b]
The AngularVelocity property of a body.
[/li]
[li][b][tt]float Body.Inertia[/tt][/b]
Rotational Inertia, body's resistance to changes in angular velocity.
[/li]
[li][b][tt]readonly float Body.LinearVelocityX[/tt][/b]
Gets the X vector from the body's Linear Velocity.
[/li]
[li][b][tt]readonly float Body.LinearVelocityY[/tt][/b]
Gets the Y vector from the body's Linear Velocity.
[/li]
[li][b][tt]void Body.SetLinearVelocity(float fx, float fy)[/tt][/b]
Set's the body LinearVelocity vector.
[/li]
[li][b][tt]void Body.ApplyForce(float fx, float fy)[/tt][/b]
Applies a force on a body from it's center [tt]0.0, 0.0[/tt] to the specified [tt]fx, fy[/tt]
direction.
[/li]
[li][b][tt]void Body.ApplyAngularImpulse(float impulseIntensity)[/tt][/b]
Applies an angular impulse on the body.
[/li]
[li][b][tt]void Body.ApplyLinearImpulse(float intensity_x, float intensity_y)[/tt][/b]
Applies an impulse from the body center with the specified vector.
[/li]
[li][b][tt]void Body.ApplyTorque(float torque)[/tt][/b]
Applies a torque on the body. Positive values are counter clockwise.
[/li]
[li][b][tt]bool Body.IsTouching(Body* otherBody)[/tt][/b]
Returns true when a body is in contact (being touched) by other body.
This function only evaluates at the current time, so prefer using it for resting states.
[/li]
[/list]
[i][b]World[/b][/i]
The world holds all the information needed for the physics simulation.
Once a world is destroyed, the previous pointers (Bodies, Fixtures, ...) will be of no use and you will need to recreate any objects you need in the new world.
[list]
[li][b][tt]void World.Step(float dt, int velocityIteractions = 8, int positionIteractions = 3)[/tt][/b]
Advances a step in the World physics simulation of [tt]dt[/tt] seconds.
Because AGS uses fixed game steps, a good value is [tt]dt = 1.0/IntToFloat(GetGameSpeed())[/tt].
velocityIteractions and positionIteractions relates to how Box2D simulates the world, so for information on these values I recommend looking into Box2D own documentation.
[/li]
[li][b][tt]int World.GetDebugSprite(int camera_x = 0, int camera_y = 0)[/tt][/b]
Returns a sprite of the size of the screen with the objects in the world drawn on it.
A common usage is to create a GUI of the size of the screen and set the background graphic of it with the sprite this function outputs. Set this GUI transparency between 1 and 99.
You can pass a camera x and y value to scroll the camera on the world.
[/li]
[li][b][tt]int FixtureArray* World.BoundingBoxQuery(float lower_x, float lower_y, float upper_x, float upper_y)[/tt][/b]
Returns array of fixtures which their bounding boxes are overlapped by the supplied box.
A fixture bounding box is the non rotated smallest rectangle that contains it's shape, this means a rotate rectangle or a circle, a empty area is part of the bounding box.
This is usually good enough for a first stage of a detection, but may require additional steps.
[/li]
[li][b][tt]int RaycastResult* World.Raycast(float x0, float y0, float x1, float y1, RaycastType rc_type = 0, FixtureArray* stopping_fixtures = 0)[/tt][/b]
Returns RaycastResult with fixtures hit by a line, along with the hit normals.
The raycast goes through all fixtures on the line if you supply [tt]eRaycastPassthrough[/tt] (this is the default).
You can use [tt]eRaycastUntilHit[/tt] for it to stop at the first fixture hit, or additionally supply an array of target fixtures so that the raycast only stops if hit any fixture on the array.
[/li]
[li][b][tt]readonly int World.ContactCount[/tt][/b]
How many contacts are available. Use it to know the range to access [tt]World.Contacts[][/tt].
[/li]
[li][b][tt]readonly Contact* World.Contacts[][/tt][/b]
Gets the contacts in the world by index. These only contain fixtures in contact right now.
[/li]
[/list]
[i][b]Shape[/b][/i]
[list]
[li][b][tt]ShapeRectangle* Shape.AsRectangle[/tt][/b]
If the shape is a ShapeRectangle, it returns it. Otherwise, it returns [tt]null[/tt].
You should not hold pointers to it, and instead access it directly like [tt]myshape.AsRectangle.Width[/tt] as needed.
[/li]
[li][b][tt]ShapeCircle* Shape.AsCircle[/tt][/b]
If the shape is a ShapeCircle, it returns it. Otherwise, it returns [tt]null[/tt].
You should not hold pointers to it, and instead access it directly like [tt]myshape.AsCircle.Radius[/tt] as needed.
[/li]
[/list]
[i][b]Fixture[/b][/i]
Fixtures are used when linking a shape to an object and assigning it's density.
[list]
[li][b][tt]float Fixture.Density[/tt][/b]
Density is used to compute the mass of the linked body. It's preferable to use similar densities to all your fixtures, because this will improve the simulation.
[/li]
[li][b][tt]float Fixture.Friction[/tt][/b]
Friction is used to make objects slide along each other realistically.
It's usually a value between [tt]0.0[/tt] and [tt]1.0[/tt], but can be any non-negative value.
Box2D uses the square root of the multiplication of two contacting fixtures to calculate the contact friction. This means if one fixture has [tt]0.0[/tt] friction, the contact will have no friction.
[/li]
[li][b][tt]float Fixture.Restitution[/tt][/b]
Restitution is used to make objects bounce, and is usually a value between [tt]0.0[/tt] and [tt]1.0[/tt]. A value of [tt]0.0[/tt] means the object won't bounce, and a value of [tt]1.0[/tt] means the object velocity will be exactly reflected.
[/li]
[li][b][tt]readonly Body* Fixture.Body[/tt][/b]
Returns Body if it's defined for this fixture, otherwise null.
[/li]
[li][b][tt]int Fixture.GroupIndex[/tt][/b]
Group the fixture belongs to, from -32768 to 32767. Fixtures with the same group will always collide if group is positive or never collide if it's negative.
Zero means no group, and is default.
[/li]
[li][b][tt]int Fixture.CategoryBits[/tt][/b]
Category of this fixture, from 16 possible categories encoded as 16-bit integer (1, 2, 4, 8, ... 32768). 65535 means all categories.
[/li]
[li][b][tt]int Fixture.MaskBits[/tt][/b]
Mask of this fixture, encoded as 16-bit integer. Categories selected will collide with this fixture (ex: 5, means category 1 and 4 will collide). Default is 65535 - collide with all categories.
[/li]
[li][b][tt]bool Fixture.TestPoint(float x, float y)`[/tt][/b]
Returns true if a point is inside the shape of the fixture.
[/li]
[li][b][tt]bool Fixture.IsSensor[/tt][/b]
Whether this fixture is a sensor. Sensors do not cause collision responses, but generate begin-contact and end-contact events.
[/li]
[/list]
[i][b]Joint[/b][/i]
Joints are used to link a body to another to create relative movements.
[list]
[li][b][tt]JointDistance* Joint.AsDistance[/tt][/b]
If this joint is a distance joint, returns the JointDistance interface; otherwise null.
[/li]
[li][b][tt]JointMotor* Joint.AsMotor[/tt][/b]
If this joint is a motor joint, returns the JointMotor interface; otherwise null.
[/li]
[li][b][tt]JointMouse* Joint.AsMouse[/tt][/b]
If this joint is a mouse joint, returns the JointMouse interface; otherwise null.
[/li]
[li][b][tt]JointPulley* Joint.AsPulley[/tt][/b]
If this joint is a pulley joint, returns the JointPulley interface; otherwise null.
[/li]
[li][b][tt]bool Joint.IsValid[/tt][/b]
If this joint is valid, returns true.
[/li]
[li][b][tt]bool Joint.IsActive[/tt][/b]
If this joint is active, returns true.
[/li]
[li][b][tt]Body* Joint.BodyA[/tt][/b]
Returns Body A if it's defined, otherwise null, for this joint.
[/li]
[li][b][tt]Body* Joint.BodyB[/tt][/b]
Returns Body B if it's defined, otherwise null, for this joint.
[/li]
[li][b][tt]JointType Joint.Type[/tt][/b]
Returns this joint type.
[/li]
[/list]
[i][b]JointDistance[/b][/i]
[list]
[li][b][tt]float JointDistance.Length[/tt][/b]
The equilibrium distance between the two Bodies.
[/li]
[li][b][tt]float JointDistance.DampingRatio[/tt][/b]
The damping ratio, typically between 0 and 1. At 1, the damping is critical.
[/li]
[li][b][tt]float JointDistance.Frequency[/tt][/b]
The frequency of a harmonic oscillator. Should be smaller than half the frame rate.
[/li]
[/list]
[i][b]JointMotor[/b][/i]
[list]
[li][b][tt]void JointMotor.SetLinearOffset(float fx, float fy)[/tt][/b]
Sets the target linear offset between the two bodies the joint is attached to.
[/li]
[li][b][tt]float JointMotor.LinearOffsetX[/tt][/b]
The target linear offset X axis between the two bodies the joint is attached to.
[/li]
[li][b][tt]float JointMotor.LinearOffsetY[/tt][/b]
The target linear offset Y axis between the two bodies the joint is attached to.
[/li]
[li][b][tt]float JointMotor.AngularOffset[/tt][/b]
The target angular offset between the two bodies the joint is attached to.
[/li]
[li][b][tt]float JointMotor.MaxForce[/tt][/b]
The Maximum Force applied to reach target position.
[/li]
[li][b][tt]float JointMotor.MaxTorque[/tt][/b]
The Maximum Torque applied to reach target rotation.
[/li]
[/list]
[i][b]JointMouse[/b][/i]
[list]
[li][b][tt]void JointMouse.SetTarget(float fx, float fy)[/tt][/b]
Sets the target point.
[/li]
[li][b][tt]float JointMouse.TargetX[/tt][/b]
The target point X axis.
[/li]
[li][b][tt]float JointMouse.TargetY[/tt][/b]
The target point Y axis.
[/li]
[li][b][tt]float JointMouse.DampingRatio[/tt][/b]
The damping ratio, typically between 0 and 1. At 1, the damping is critical.
[/li]
[li][b][tt]float JointMouse.Frequency[/tt][/b]
The frequency of a harmonic oscillator. Should be smaller than half the frame rate.
[/li]
[li][b][tt]float JointMouse.MaxForce[/tt][/b]
The Maximum Force applied to reach target position.
[/li]
[/list]
[i][b]JointPulley[/b][/i]
[list]
[li][b][tt]float JointPulley.LengthA[/tt][/b]
The current length of the segment attached to the first body.
[/li]
[li][b][tt]float JointPulley.LengthB[/tt][/b]
The current length of the segment attached to the second body.
[/li]
[li][b][tt]float JointPulley.Ratio[/tt][/b]
The pulley ratio.
[/li]
[/list]
[i][b]Contact[/b][/i]
Contact are returned to inform a contact is happening, between two fixtures. They also include additional useful information.
[list]
[li][b][tt]readonly bool Contact.IsValid[/tt][/b]
Whether the Contact is still valid.
[/li]
[li][b][tt]readonly PointF* Contact.Normal[/tt][/b]
The normal vector between two shapes that are in contact.
[/li]
[li][b][tt]readonly PointF* Contact.Positions[][/tt][/b]
The contact points of the two colliding fixture, use PositionsCount to find out how many. Index starts at 0.
[/li]
[li][b][tt]readonly int Contact.PositionsCount[/tt][/b]
How many position of contact are available.
[/li]
[li][b][tt]readonly Fixture* Contact.FixtureA[/tt][/b]
One of the Fixtures that hold the shapes in contact.
[/li]
[li][b][tt]readonly Fixture* Contact.FixtureB[/tt][/b]
The other of the Fixtures that hold the shapes in contact.
[/li]
[li][b][tt]bool Contact.Enabled[/tt][/b]
Whether the contact is enabled.
[/li]
[li][b][tt]float Contact.Restitution[/tt][/b]
The restitution between two shapes that are in contact.
[/li]
[li][b][tt]float Contact.Friction[/tt][/b]
The friction between two shapes that are in contact.
[/li]
[/list][/spoiler]
[b][size=12pt]Download AgsBox2D[/size][/b]
[spoiler]This plugin is available as [tt]agsbox2d.dll[/tt] under [url=https://github.com/ericoporto/agsbox2d/releases/latest/]assets, in the latest release[/url], for usage with Windows and the AGS Editor. You can also find it there built for Linux as [tt]libagsbox2d.so[/tt] and for MacOS as [tt]libagsbox2d.dylib[/tt].[/spoiler]
[b][size=12pt]Building agsbox2d[/size][/b]
[spoiler]
AgsBox2D both Makefile and the VS Solution file, expects to find [url=https://github.com/adventuregamestudio/ags]Adventure Game Studio source code[/url] in a folder [tt]../ags/[/tt]. After you do this, you need to clone this source code.
[code] ~/git/ags/
~/git/agsbox2d/[/code]
Navigate then to the directory where you cloned this repository.
On Windows, you can load the solution on the root of it's directory and load it on Visual Studio. It should work with VS 2015, 2017 and 2019. You will need v140 tools (VS should promptly warn you to install if you don't have it).
The dll provided by Release Win32 builds is the one you should build to use with an AGS Game at the time of this writing.
On Linux and MacOS, navigate to [tt]agsbox2d/[/tt] inside the directory and type [tt]make[/tt].[/spoiler]
[b][size=12pt]License and Author[/size][/b]
AgsBox2D is made by eri0o provided with Z-Lib [url=https://github.com/ericoporto/agsbox2d/blob/master/LICENSE]LICENSE[/url].
Box2D itself is made by Erin Catto and is provided with a Z-Lib [url=https://github.com/ericoporto/agsbox2d/blob/master/Box2D/Box2D/LICENSE]LICENSE[/url] too.