CreateMouseJoint

Family: 2DPhysics · 2 forms

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) → integer

Parameters

NameTypeIn forms
jointIDinteger1
spriteIDintegerall
xfloatall
yfloatall
maxForcefloatall

What each form returns

1CreateMouseJoint(1, sprite, 100.0, 120.0, 1.0)nothing
2mouseJoint = 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()LOOP

Form 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()LOOP

LoadImage 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.

66 commands in 2DPhysics