Difference between revisions of "B2.ChainShape"
From GiderosMobile
| Line 2: | Line 2: | ||
<languages /> | <languages /> | ||
<!-- GIDEROSOBJ:b2.ChainShape --> | <!-- GIDEROSOBJ:b2.ChainShape --> | ||
| − | ''' | + | '''Supported platforms:''' [[File:Platform android.png]][[File:Platform ios.png]][[File:Platform mac.png]][[File:Platform pc.png]][[File:Platform html5.png]][[File:Platform winrt.png]][[File:Platform win32.png]]<br/> |
| − | ''' | + | '''Available since:''' Gideros 2012.2.2<br/> |
| − | ''' | + | '''Inherits from:''' [[Special:MyLanguage/b2.Shape|b2.Shape]]<br/> |
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | + | === 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. |
| − | + | ||
| − | '''Create world bounds using ChainShape''' | + | '''Note''': the chain will not collide properly if there are self-intersections. |
| − | <source lang="lua">local body = world:createBody{type = b2.STATIC_BODY} | + | |
| + | === Examples === | ||
| + | '''Create world bounds using ChainShape''' | ||
| + | <source lang="lua"> | ||
| + | local body = world:createBody{type = b2.STATIC_BODY} | ||
body:setPosition(0, 0) | body:setPosition(0, 0) | ||
local chain = b2.ChainShape.new() | local chain = b2.ChainShape.new() | ||
| Line 26: | Line 23: | ||
0, application:getContentHeight() | 0, application:getContentHeight() | ||
) | ) | ||
| − | local fixture = body:createFixture{shape = chain, density = 1.0, | + | local fixture = body:createFixture{shape = chain, density = 1.0, friction = 1, restitution = 0.3} |
| − | friction = 1, restitution = 0.3}</source> | + | </source> |
| + | |||
{|- | {|- | ||
| style="width: 50%; vertical-align:top;"| | | style="width: 50%; vertical-align:top;"| | ||
| − | === | + | === Methods === |
[[Special:MyLanguage/b2.ChainShape.new|b2.ChainShape.new]] <br/><!-- GIDEROSMTD:b2.ChainShape.new() --> | [[Special:MyLanguage/b2.ChainShape.new|b2.ChainShape.new]] <br/><!-- GIDEROSMTD:b2.ChainShape.new() --> | ||
| − | [[Special:MyLanguage/b2.ChainShape:createChain|b2.ChainShape:createChain]] '' | + | [[Special:MyLanguage/b2.ChainShape:createChain|b2.ChainShape:createChain]] ''creates a chain with isolated end vertices''<br/><!-- GIDEROSMTD:b2.ChainShape:createChain(vertices) creates a chain with isolated end vertices --> |
| − | [[Special:MyLanguage/b2.ChainShape:createLoop|b2.ChainShape:createLoop]] '' | + | [[Special:MyLanguage/b2.ChainShape:createLoop|b2.ChainShape:createLoop]] ''creates a loop''<br/><!-- GIDEROSMTD:b2.ChainShape:createLoop(vertices) creates a loop --> |
| + | |||
| style="width: 50%; vertical-align:top;"| | | style="width: 50%; vertical-align:top;"| | ||
| − | === | + | === Events === |
| − | === | + | === Constants === |
|} | |} | ||
| − | + | ---- | |
| + | *'''[[LiquidFun]]''' | ||
Revision as of 07:00, 17 February 2020
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 |