What it does
CreateMouseJoint brings a 2DPhysics object into being: it is how the rest of the program comes to have one. It takes jointID (an integer), spriteID (an integer), x (a float), y (a float) and maxForce (a float), and returns nothing. That is the first of 2 forms. jointID is the id you are giving a Joint object: every later call names it by that number.
Syntax
1
CreateMouseJoint(jointID integer, spriteID integer, x float, y float, maxForce float)2
CreateMouseJoint(spriteID integer, x float, y float, maxForce float) → integerParameters
| Name | Type | In forms |
|---|---|---|
| jointID | integer | 1 |
| spriteID | integer | all |
| x | float | all |
| y | float | all |
| maxForce | float | all |
What each form returns
| 1 | CreateMouseJoint(1, sprite, 100.0, 120.0, 1.0) | nothing |
| 2 | mouseJoint = CreateMouseJoint(sprite, 100.0, 120.0, 1.0) | integer |
Example · generated
Form 1, you choose the id yourself
image = LoadImage("assets/sprite.png", 1)sprite = CreateSprite(image)CreateMouseJoint(1, sprite, 100.0, 120.0, 1.0)DO Sync()LOOPForm 2, the command hands back the id
image = LoadImage("assets/sprite.png", 1)sprite = CreateSprite(image)mouseJoint = CreateMouseJoint(sprite, 100.0, 120.0, 1.0)DO Sync()LOOPLoadImage and CreateSprite are there to give the call something to act on; CreateMouseJoint is the line that matters. The DO … LOOP is not decoration: a classic BASIC program ends the moment it runs out of lines, and Sync() is what draws the frame.