Hi
So i’ve been playing around with the tests that came with cocos2d html and want to know
if i can disable the elacticity/bouncyness of a Physics sprite and the floor/walls, which means i want only the gravity remaining.
I set the elasticity value to 0 but it worked only half way
for examle in Chimunk Sprite Test
// init physics
ChipmunkSprite.prototype.initPhysics = function() {
var space = this.space ;
var staticBody = space.staticBody;
// Walls
var walls = [ new cp.SegmentShape( staticBody, cp.v(0,0), cp.v(winSize.width,0), 0 ), // bottom
new cp.SegmentShape( staticBody, cp.v(0,winSize.height), cp.v(winSize.width,winSize.height), 0), // top
new cp.SegmentShape( staticBody, cp.v(0,0), cp.v(0,winSize.height), 0), // left
new cp.SegmentShape( staticBody, cp.v(winSize.width,0), cp.v(winSize.width,winSize.height), 0) // right
];
for( var i=0; i < walls.length; i++ ) {
var shape = walls[i];
shape.setElasticity(0); // Elasticity -> 0
shape.setFriction(100);
space.addStaticShape( shape );
}
// Gravity
space.gravity = cp.v(0, -100);
};
ChipmunkSprite.prototype.createPhysicsSprite = function( pos ) {
var body = new cp.Body(1, cp.momentForBox(1, 48, 108) );
body.setPos( pos );
this.space.addBody( body );
var shape = new cp.BoxShape( body, 48, 108);
shape.setElasticity( 0 ); // Elasticity -> 0
shape.setFriction( 100 );
this.space.addShape( shape );
var sprite = cc.PhysicsSprite.create(s_pathGrossini);
sprite.setBody( body );
return sprite;
};
Is it possible or should i use another approach, thx in advance and
thx a lot for this framework