Difference between revisions of "B2.ChainShape"
From GiderosMobile
m (Text replacement - "<source" to "<syntaxhighlight") |
|||
(One intermediate revision by the same user not shown) | |||
Line 13: | Line 13: | ||
=== Examples === | === Examples === | ||
'''Create world bounds using ChainShape''' | '''Create world bounds using ChainShape''' | ||
− | < | + | <syntaxhighlight lang="lua"> |
local body = world:createBody{type = b2.STATIC_BODY} | local body = world:createBody{type = b2.STATIC_BODY} | ||
body:setPosition(0, 0) | body:setPosition(0, 0) | ||
Line 24: | Line 24: | ||
) | ) | ||
local fixture = body:createFixture{shape = chain, density = 1.0, friction = 1, restitution = 0.3} | local fixture = body:createFixture{shape = chain, density = 1.0, friction = 1, restitution = 0.3} | ||
− | </ | + | </syntaxhighlight> |
{|- | {|- |
Latest revision as of 16:56, 12 July 2023
Supported platforms:
Available since: Gideros 2012.2.2
Inherits from: b2.Shape
Description
A chain shape is a free form sequence of line segments. The chain has two-sided collision, so you can use inside and outside collision. Therefore, you may use any winding order. Connectivity information is used to create smooth collisions.
Note: the chain will not collide properly if there are self-intersections.
Examples
Create world bounds using ChainShape
local body = world:createBody{type = b2.STATIC_BODY}
body:setPosition(0, 0)
local chain = b2.ChainShape.new()
chain:createLoop(
0,0,
application:getContentWidth(), 0,
application:getContentWidth(), application:getContentHeight(),
0, application:getContentHeight()
)
local fixture = body:createFixture{shape = chain, density = 1.0, friction = 1, restitution = 0.3}
Methodsb2.ChainShape.new |
EventsConstants |