WEB开发网
开发学院图形图像Flash A smart way to manage sleeping objects with Bo... 阅读

A smart way to manage sleeping objects with Box2D

 2009-10-31 00:00:00 来源:WEB开发网   
核心提示: In the on_time function I added some lines to assign a cubeface object to the rectangle I create.The cubeface object is just a MovieClip with two fr

In the on_time function I added some lines to assign a cubeface object to the rectangle I create.

The cubeface object is just a MovieClip with two frames, one with an happy box and one with a sad one.

Line 43: Assigning the cubeface object to the rectangle

Lines 44-45: Defining movieclip width and height

Line 53: Adding the movieclip on the stage

Later, in the on_enter_frame function, you can find the classic Box2d function used to update sprites (or movieclips) position and rotation.

Lines 62-67: Checking if the body is sleeping with IsSleeping. If the body is sleeping, then stop the movieclip on frame 2 (the happy square), otherwise stop it on frame 1 (the afraid square).

This is the result

本文示例源代码或素材下载

上一页  1 2 

Tags:smart way to

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