Core.prototype.setArms()
The setArms() method sets arm graphic elements. By default, the back layer is used.
Suppose right0 is the right forearm, right1 is the right upper arm, left0 is the left forearm, and left1 is the left upper arm, the element list will be an array of arrays like this:
[
[ right0, right1 ],
[ left0, left1 ],
]
The graphic elements specified here are added to the drawing layer. These can be moved by calling drawArms(), and calling drawArms() will only move the elements specified here or the default.
All graphic elements specified here must be SVGLineElement objects (<line> tags) connecting the two points.
If the number of arms or parts is different from the default, specify the number of elements you want.
[
[ arm00, arm01, arm02, arm03, ... ],
[ arm10, arm11, arm12, arm13, ... ],
[ arm20, arm21, arm22, arm23, ... ],
...
]
Syntax
setArms(arms)
setArms(arms, layer)
Parameters
- arms
- An array of arrays of graphic elements for each arm.
- layer (Optional)
- A drawing layer on which to place graphic elements.
- If this argument is omitted, the graphic elements are placed on Core.prototype.back.
- In either case, existing arm elements are deleted.
Return value
none
Examples
const core = new jmotion.Core("#board", true);
const arm = [
[
document.getElementById("arm0"),
document.getElementById("arm1"),
document.getElementById("arm2"),
],
];
core.setArms(arm);
// core.back = {
// "arm0": line#arm0,
// "arm1": line#arm1,
// "arm2": line#arm2,
// }