Difference between revisions of "B2.CircleShape"

From GiderosMobile
Line 2: Line 2:
 
<languages />
 
<languages />
 
<!-- GIDEROSOBJ:b2.CircleShape -->
 
<!-- GIDEROSOBJ:b2.CircleShape -->
'''<translate>Supported platforms</translate>:''' [[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/>
+
'''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/>
'''<translate>Available since</translate>:''' Gideros 2011.6<br/>
+
'''Available since:''' Gideros 2011.6<br/>
'''<translate>Inherits from</translate>:''' [[Special:MyLanguage/b2.Shape|b2.Shape]]<br/>
+
'''Inherits from:''' [[Special:MyLanguage/b2.Shape|b2.Shape]]<br/>
=== <translate>Description</translate> ===
+
 
<translate><br />
+
=== Description ===
A circle shape.<br />
+
A circle shape.
<br /></translate>
+
 
=== <translate>Examples</translate> ===
+
=== Examples ===
'''Creating a circle body'''<br/>
+
'''Creating a circle body'''
<source lang="lua">--create ball bitmap object from ball graphic
+
<source lang="lua">
 +
--create ball bitmap object from ball graphic
 
local ball = Bitmap.new(Texture.new("./ball.png"))
 
local ball = Bitmap.new(Texture.new("./ball.png"))
 
--reference center of the ball for positioning
 
--reference center of the ball for positioning
 
ball:setAnchorPoint(0.5,0.5)
 
ball:setAnchorPoint(0.5,0.5)
 
 
ball:setPosition(x,y)
 
ball:setPosition(x,y)
 
 
--get radius
 
--get radius
 
local radius = ball:getWidth()/2
 
local radius = ball:getWidth()/2
Line 27: Line 26:
 
local circle = b2.CircleShape.new(0, 0, radius)
 
local circle = b2.CircleShape.new(0, 0, radius)
 
local fixture = body:createFixture{shape = circle, density = 1.0,  
 
local fixture = body:createFixture{shape = circle, density = 1.0,  
friction = 0.1, restitution = 0.2}</source>
+
friction = 0.1, restitution = 0.2}
 +
</source>
 +
 
 
{|-
 
{|-
 
| style="width: 50%; vertical-align:top;"|
 
| style="width: 50%; vertical-align:top;"|
=== <translate>Methods</translate> ===
+
=== Methods ===
 
[[Special:MyLanguage/b2.CircleShape.new|b2.CircleShape.new]] <br/><!-- GIDEROSMTD:b2.CircleShape.new(centerx,centery,radius)  -->
 
[[Special:MyLanguage/b2.CircleShape.new|b2.CircleShape.new]] <br/><!-- GIDEROSMTD:b2.CircleShape.new(centerx,centery,radius)  -->
[[Special:MyLanguage/b2.CircleShape:set|b2.CircleShape:set]] ''<translate>sets the center point and radius</translate>''<br/><!-- GIDEROSMTD:b2.CircleShape:set(centerx,centery,radius) sets the center point and radius -->
+
[[Special:MyLanguage/b2.CircleShape:set|b2.CircleShape:set]] ''sets the center point and radius''<br/><!-- GIDEROSMTD:b2.CircleShape:set(centerx,centery,radius) sets the center point and radius -->
 +
 
 
| style="width: 50%; vertical-align:top;"|
 
| style="width: 50%; vertical-align:top;"|
=== <translate>Events</translate> ===
+
=== Events ===
=== <translate>Constants</translate> ===
+
=== Constants ===
 
|}
 
|}
  
{{GIDEROS IMPORTANT LINKS}}
+
----
 +
*'''[[LiquidFun]]'''

Revision as of 07:18, 17 February 2020


Supported platforms: Platform android.pngPlatform ios.pngPlatform mac.pngPlatform pc.pngPlatform html5.pngPlatform winrt.pngPlatform win32.png
Available since: Gideros 2011.6
Inherits from: b2.Shape

Description

A circle shape.

Examples

Creating a circle body

--create ball bitmap object from ball graphic
local ball = Bitmap.new(Texture.new("./ball.png"))
--reference center of the ball for positioning
ball:setAnchorPoint(0.5,0.5)
ball:setPosition(x,y)
--get radius
local radius = ball:getWidth()/2
 
--create box2d physical object
local body = world:createBody{type = b2.DYNAMIC_BODY}
body:setPosition(ball:getX(), ball:getY())
body:setAngle(ball:getRotation() * math.pi/180)
local circle = b2.CircleShape.new(0, 0, radius)
local fixture = body:createFixture{shape = circle, density = 1.0, 
friction = 0.1, restitution = 0.2}

Methods

b2.CircleShape.new
b2.CircleShape:set sets the center point and radius

Events

Constants