- Box2D for Flash Games
- Emanuele Feronato
- 156字
- 2021-08-05 18:44:26
Creating a circular shape
A shape is a 2D geometrical object, such as a circle or a polygon, which in this case must be convex (every internal angle must be less than 180 degrees). Remember, Box2D can only handle convex shapes.
At the moment, we are starting with the ball, so we'll create the circle:
var circleShape:b2CircleShape; circleShape=new b2CircleShape(25/worldScale);
b2CircleShape
is used to create a circular shape, and its constructor wants the radius as an argument. With the previous lines, we are creating a circle whose radius is 25
pixels, thanks to our friend—the worldScale
variable. From now on, every time you want to work with pixels, you'll have to divide them by worldScale
. You can also define a function called, let's say, pixelsToMeters
, and call it every time you need to convert pixels to meters.
When we have a body definition and a shape, we can glue them together using a fixture.
- PyTorch深度學(xué)習(xí)實(shí)戰(zhàn):從新手小白到數(shù)據(jù)科學(xué)家
- SQL入門(mén)經(jīng)典(第5版)
- 計(jì)算機(jī)信息技術(shù)基礎(chǔ)實(shí)驗(yàn)與習(xí)題
- Modern Programming: Object Oriented Programming and Best Practices
- 數(shù)據(jù)庫(kù)原理與應(yīng)用(Oracle版)
- 智能數(shù)據(jù)分析:入門(mén)、實(shí)戰(zhàn)與平臺(tái)構(gòu)建
- Spark大數(shù)據(jù)編程實(shí)用教程
- 深入淺出 Hyperscan:高性能正則表達(dá)式算法原理與設(shè)計(jì)
- MATLAB Graphics and Data Visualization Cookbook
- 大數(shù)據(jù)技術(shù)入門(mén)
- 高維數(shù)據(jù)分析預(yù)處理技術(shù)
- PostgreSQL指南:內(nèi)幕探索
- 數(shù)據(jù)庫(kù)技術(shù)及應(yīng)用
- 計(jì)算機(jī)視覺(jué)
- Hands-On System Programming with C++