Difference between revisions of "B2.CircleShape"
From GiderosMobile
m (Text replacement - "</source" to "</syntaxhighlight") |
|||
(17 intermediate revisions by 2 users not shown) | |||
Line 1: | Line 1: | ||
__NOTOC__ | __NOTOC__ | ||
− | '''Supported platforms:''' android | + | <languages /> |
+ | <!-- GIDEROSOBJ:b2.CircleShape --> | ||
+ | '''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 2011.6<br/> | '''Available since:''' Gideros 2011.6<br/> | ||
+ | '''Inherits from:''' [[Special:MyLanguage/b2.Shape|b2.Shape]]<br/> | ||
+ | |||
=== Description === | === Description === | ||
− | < | + | A circle shape. |
− | + | ||
− | + | === Examples === | |
+ | '''Creating a circle body''' | ||
+ | <syntaxhighlight lang="lua"> | ||
+ | --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} | ||
+ | </syntaxhighlight> | ||
+ | |||
{|- | {|- | ||
− | | style="width: 50%;"| | + | | style="width: 50%; vertical-align:top;"| |
=== Methods === | === Methods === | ||
− | [[b2.CircleShape.new]] | + | [[Special:MyLanguage/b2.CircleShape.new|b2.CircleShape.new]] <br/><!-- GIDEROSMTD:b2.CircleShape.new(centerx,centery,radius) --> |
− | [[b2.CircleShape:set]] | + | [[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%;"| | + | |
+ | | style="width: 50%; vertical-align:top;"| | ||
=== Events === | === Events === | ||
=== Constants === | === Constants === | ||
|} | |} | ||
+ | |||
+ | ---- | ||
+ | *'''[[B2.Shape]]''' | ||
+ | *'''[[LiquidFun]]''' |
Latest revision as of 17:18, 12 July 2023
Supported platforms:
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}
Methodsb2.CircleShape.new |
EventsConstants |