WEB开发网
开发学院图形图像Flash Introducing Box2D filtering 阅读

Introducing Box2D filtering

 2009-10-18 00:00:00 来源:WEB开发网   
核心提示: Let’s see the new lines:Line 44: Assigning the ground object the collision category 2 using filter.categoryBitsLine 55: Assigning the obstacle

Let’s see the new lines:

Line 44: Assigning the ground object the collision category 2 using filter.categoryBits

Line 55: Assigning the obstacle the collision category 4 using filter.categoryBits

Remember categories must follow the power of two so next group would be 8 and not 5

Line 70: randomly assigning 2, 4 or 6 to ball collision mask using filter.maskBits. When it’s 2, the ball will collide only with objects in category 2, when it’s 4 the ball will collide only with objects in category 4 and when it’s 6 the ball will collide with objects both in category 2 and 4, because 4+2=6.

And this is the result:

Watch the ball changing its behavior according to objects it can collide with.

上一页  1 2 

Tags:Introducing BoxD filtering

编辑录入:爽爽 [复制链接] [打 印]
赞助商链接