Win an Ipad
  Developer   Documents   PhysicsSprite

PhysicsSprite

PhysicsSprite allows to create bodies with complicated shapes and simplifies image drawing into the body. It takes advanteges of Game2d.Sprite class.

PhysicsSprite.create factory has seven parameters:

- instance of PhysicsScene

- body shape (instance of b2CircleShape or b2PolygonShape)

- image which may be drawn into the body

- body type

- density

- friction

- bounce

- calledClass, optional parameter to define what class requested creation of the PhysicsSprite.

The class has almost all functions and properties from native b2Body.

include "lib://box2d/physicsSprite.ms"; class Ball : PhysicsSprite
{
    var BALL_IMG = Bitmap.fromFile("app://ball.png");     function init()
    {
        super.init();         this.image = BALL_IMG;
        this.radius = 14.0;
        this.shape = null;
        this.shapeType = #circle;
        this.bodyType = #dynamic;
        this.density = 0.0;
        this.friction = 0.0;
        this.bounce = 1.0;     } } var ball = new Ball({scene:this}); //create box2d body ball._createBody(); //set position into middle of the screen
ball.setPosition(System.width / 2, System.height / 2);

 PhysicsScene   PhysicsSprite   Game Engine 
Write a Comment (0)
Subject
Please complete this mandatory field.
HTML Tags Not Allowed!
Comment
Please complete this mandatory field.