Difference between revisions of "B2.ChainShape"

From GiderosMobile
m (Text replacement - "<source" to "<syntaxhighlight")
 
(20 intermediate revisions by 3 users not shown)
Line 1: Line 1:
 
__NOTOC__
 
__NOTOC__
'''Supported platforms:''' android, ios, mac, pc<br/>
+
<languages />
 +
<!-- 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/>
 
'''Available since:''' Gideros 2012.2.2<br/>
 +
'''Inherits from:''' [[Special:MyLanguage/b2.Shape|b2.Shape]]<br/>
 +
 
=== Description ===
 
=== Description ===
<translate><br />
+
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.
A chain shape is a free form sequence of line segments. The chain has two-sided collision, so you can use inside <br />
+
 
and outside collision. Therefore, you may use any winding order. Connectivity information is used to create smooth collisions.<br />
+
'''Note''': the chain will not collide properly if there are self-intersections.
<br />
+
 
&lt;ul&gt;<br />
 
&lt;li&gt;*Note:** The chain will not collide properly if there are self-intersections.&lt;/li&gt;<br />
 
&lt;/ul&gt;<br />
 
<br /></translate>
 
 
=== Examples ===
 
=== Examples ===
'''Create world bounds using ChainShape'''<br/>
+
'''Create world bounds using ChainShape'''
<source lang="lua">local body = world:createBody{type = b2.STATIC_BODY}
+
<syntaxhighlight 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 22: 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>
+
</syntaxhighlight>
 +
 
 
{|-
 
{|-
| style="width: 50%;"|
+
| style="width: 50%; vertical-align:top;"|
 
=== Methods ===
 
=== Methods ===
[[b2.ChainShape.new]] - <br/>
+
[[Special:MyLanguage/b2.ChainShape.new|b2.ChainShape.new]] <br/><!-- GIDEROSMTD:b2.ChainShape.new()  -->
[[b2.ChainShape:createChain]] - creates a chain with isolated end vertices<br/>
+
[[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 -->
[[b2.ChainShape:createLoop]] - creates a loop<br/>
+
[[Special:MyLanguage/b2.ChainShape:createLoop|b2.ChainShape:createLoop]] ''creates a loop''<br/><!-- GIDEROSMTD:b2.ChainShape:createLoop(vertices) creates a loop -->
| style="width: 50%;"|
+
 
 +
| style="width: 50%; vertical-align:top;"|
 
=== Events ===
 
=== Events ===
 
=== Constants ===
 
=== Constants ===
 
|}
 
|}
 +
 +
----
 +
*'''[[B2.Shape]]'''
 +
*'''[[LiquidFun]]'''

Latest revision as of 16:56, 12 July 2023


Supported platforms: Platform android.pngPlatform ios.pngPlatform mac.pngPlatform pc.pngPlatform html5.pngPlatform winrt.pngPlatform win32.png
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}

Methods

b2.ChainShape.new
b2.ChainShape:createChain creates a chain with isolated end vertices
b2.ChainShape:createLoop creates a loop

Events

Constants