Cocos2d-js Chipmunk Physics Engine related (1)

Source: Internet
Author: User

Recently see some cocos2d-js things, use the chipmunk of some of the things, because the relevant information is not very detailed, so see something useful on the record.

1. Chipmunk is a physical engine of the cocos2d that simulates the reality of gravity, collisions, and so on.

A chipmunk body represents an object in a virtual space and may contain one or more chipmunk shapes to form its geometry.

For example, a dynamic Chipmunk object is added to the scene:

Initialization

        This.body = new CP. Body (1, Cp.momentforbox (Mass, boxsize.width, boxsize.height));
Set Position:
        THIS.BODY.P = CC.P (loaction);
Use CP. Body to create an object requires two parameters, namely the mass mass and the moment of inertia, and Cp.momentforbox calculates the inertial moment according to the Mass and shape size of the entry and exit.

THIS.BODY.P = CC.P (X, Y);

BODY.P can be used to define the centroid of a rigid body object.

Force or impulse can be applied to a rigid body by means of applyforce or applylmpulse.


Cocos2d-js Chipmunk Physics Engine related (1)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.