Difference between revisions of "B2.ChainShape"

From GiderosMobile
Line 3: Line 3:
 
'''Available since:''' Gideros 2012.2.2<br/>
 
'''Available since:''' Gideros 2012.2.2<br/>
 
=== Description ===
 
=== Description ===
<br />
+
<translate><br />
 
A chain shape is a free form sequence of line segments. The chain has two-sided collision, so you can use inside <br />
 
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 />
 
and outside collision. Therefore, you may use any winding order. Connectivity information is used to create smooth collisions.<br />
Line 10: Line 10:
 
&lt;li&gt;*Note:** The chain will not collide properly if there are self-intersections.&lt;/li&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 />
 
&lt;/ul&gt;<br />
<br />
+
<br /></translate>
 
=== Examples ===
 
=== Examples ===
 
'''Create world bounds using ChainShape'''<br/>
 
'''Create world bounds using ChainShape'''<br/>

Revision as of 13:33, 23 August 2018

Supported platforms: android, ios, mac, pc
Available since: Gideros 2012.2.2

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.

<ul>
<li>*Note:** The chain will not collide properly if there are self-intersections.</li>
</ul>

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