0
starling + as3을 사용하여 모바일 앱의 무대 벽과 상자를 만듭니다.Starling + Box2d - 정밀하지 않은 충돌
좋아, 내가 응용 프로그램을 테스트 할 때, 이제 상자 폭포하지만 가있는 것처럼, 벽과 일치하지 않는 오프셋 :
https://www.dropbox.com/s/hd4ehnfthh0ucfm/box.png
다음내가 상자를 생성하는 방법입니다 (벽과 상자).
오프셋이 숨겨져있는 것처럼 보입니다. 어떻게 생각하십니까?
public function createBox(x:Number, y:Number, width:Number, height:Number, rotation:Number = 0, bodyType:uint = 0):void {
/// Vars used to create bodies
var body:b2Body;
var boxShape:b2PolygonShape;
var circleShape:b2CircleShape;
var fixtureDef:b2FixtureDef = new b2FixtureDef();
fixtureDef.shape = boxShape;
fixtureDef.friction = 0.3;
// static bodies require zero density
fixtureDef.density = 0;
var quad:Quad;
bodyDef = new b2BodyDef();
bodyDef.type = bodyType;
bodyDef.position.x = x/WORLD_SCALE;
bodyDef.position.y = y/WORLD_SCALE;
// Box
boxShape = new b2PolygonShape();
boxShape.SetAsBox(width/WORLD_SCALE, height/WORLD_SCALE);
fixtureDef.shape = boxShape;
fixtureDef.density = 0;
fixtureDef.friction = 0.5;
fixtureDef.restitution = 0.2;
// create the quads
quad = new Quad(width, height, Math.random() * 0xFFFFFF);
quad.pivotX = 0;
quad.pivotY = 0;
// this is the key line, we pass as a userData the starling.display.Quad
bodyDef.userData = quad;
//
body = m_world.CreateBody(bodyDef);
body.CreateFixture(fixtureDef);
body.SetAngle(rotation * (Math.PI/180));
_clipPhysique.addChild(bodyDef.userData);
}
그래, 나도 그 얘기를 들었다. setasbox는 돌보는 방법이다. – mirzahat