Difference between revisions of "B2.CircleShape"

From GiderosMobile
Line 1: Line 1:
 
__NOTOC__
 
__NOTOC__
 +
<!-- GIDEROSOBJ:b2.CircleShape -->
 
'''<translate>Supported platforms</translate>:''' [[File:Platform android.png]][[File:Platform ios.png]][[File:Platform mac.png]][[File:Platform pc.png]]<br/>
 
'''<translate>Supported platforms</translate>:''' [[File:Platform android.png]][[File:Platform ios.png]][[File:Platform mac.png]][[File:Platform pc.png]]<br/>
 
'''<translate>Available since</translate>:''' Gideros 2011.6<br/>
 
'''<translate>Available since</translate>:''' Gideros 2011.6<br/>
Line 29: Line 30:
 
| style="width: 50%; vertical-align:top;"|
 
| style="width: 50%; vertical-align:top;"|
 
=== <translate>Methods</translate> ===
 
=== <translate>Methods</translate> ===
[[Special:MyLanguage/b2.CircleShape.new|b2.CircleShape.new]] <br/>
+
[[Special:MyLanguage/b2.CircleShape.new|b2.CircleShape.new]] <br/><!-- GIDEROSMTD:b2.CircleShape.new -->
[[Special:MyLanguage/b2.CircleShape:set|b2.CircleShape:set]] ''<translate>sets the center point and radius</translate>''<br/>
+
[[Special:MyLanguage/b2.CircleShape:set|b2.CircleShape:set]] ''<translate>sets the center point and radius</translate>''<br/><!-- GIDEROSMTD:b2.CircleShape:set -->
 
| style="width: 50%; vertical-align:top;"|
 
| style="width: 50%; vertical-align:top;"|
 
=== <translate>Events</translate> ===
 
=== <translate>Events</translate> ===
 
=== <translate>Constants</translate> ===
 
=== <translate>Constants</translate> ===
 
|}
 
|}

Revision as of 14:54, 31 August 2018

Supported platforms: Platform android.pngPlatform ios.pngPlatform mac.pngPlatform pc.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