SHOW:
|
|
- or go back to the newest paste.
1 | physics = require("physics") | |
2 | physics.start() | |
3 | physics.setGravity(0, 0) | |
4 | physics.setDrawMode("hybrid") | |
5 | ||
6 | display.setStatusBar(display.HiddenStatusBar) | |
7 | ||
8 | local stage = display.getCurrentStage() | |
9 | ||
10 | local width = 100 | |
11 | local height = width*math.sqrt(3)/2 | |
12 | local centroidX = height/3 | |
13 | local centroidY = width/2 | |
14 | local radius = height - centroidX | |
15 | local circle = display.newCircle(0, 0, radius) | |
16 | circle:setFillColor(0, 0, 0) | |
17 | circle.strokeWidth = 1 | |
18 | circle.x = stage.width/2 | |
19 | circle.y = stage.height/2 | |
20 | ||
21 | - | local triangle = display.newLine(0, 0, -centroidX,-centroidY) |
21 | + | local triObject = display.newGroup() |
22 | local triangle = display.newLine(triObject, -centroidX,-centroidY, -centroidX, centroidY) | |
23 | - | triangle:append(-centroidX, centroidY) |
23 | + | |
24 | triangle:append(-centroidX, -centroidY) | |
25 | - | triangle.x = circle.x |
25 | + | triObject.x = circle.x |
26 | - | triangle.y = circle.y |
26 | + | triObject.y = circle.y |
27 | - | physics.addBody(triangle, { shape = { -centroidX, -centroidY, radius, 0, -centroidX, centroidY} }) |
27 | + | physics.addBody(triObject, { shape = { -centroidX, -centroidY, radius, 0, -centroidX, centroidY} }) |
28 | ||
29 | - | triangle:applyTorque(5) |
29 | + | triObject:applyTorque(5) |