嗨我之前和Box2D玩了一点,刚刚开始使用QuickBox2D,这让事情更容易。然而,我使用特定的多边形形状与使用盒子时的行为不同。所有其他属性都是相同的。我在下面列出了3个简单示例及其来源。
我真正想要的是示例1,两个对象都是poly。正如你所看到的,看起来'paddle'poly是失败的那个 - '球'(无论是一个多边形还是圆形)直接穿过它而不是像一个盒子'桨'对象一样弹跳。希望得到一些帮助或见解。
由于我只能在此阶段发布一行,the swf previews of the 3 examples can be seen here
示例1来源:
package {
import com.actionsnippet.qbox.QuickBox2D;
import com.actionsnippet.qbox.QuickObject;
import flash.display.MovieClip;
public class Eg1 extends MovieClip {
private var sim:QuickBox2D;
private var paddle:QuickObject;
private var ball:QuickObject;
public function Eg1() {
this.sim = new QuickBox2D(this);
this.paddle = this.sim.addPoly({
x:13,
y:19,
angle:0,
density:0,
draggable:false,
isBullet:true,
verts:[[-3.84,-0.67,-2.84,-1,-2.17,-0.33,2.17,-0.33,2.84,-1,3.84,-0.67,2.84,1,-2.51,1]]
});
this.ball = this.sim.addPoly({
x:13,
y:1,
restitution:1,
friction:1,
draggable:false,
isBullet:true,
verts:[[-0.34,-1,0.34,-1,0.67,-0.33,0.67,0.33,0.34,1,-0.34,1,-0.67,0.33,-0.67,-0.33]]
});
this.sim.start();
}
}}
示例2来源:
package {
import com.actionsnippet.qbox.QuickBox2D;
import com.actionsnippet.qbox.QuickObject;
import flash.display.MovieClip;
public class Eg2 extends MovieClip {
private var sim:QuickBox2D;
private var paddle:QuickObject;
private var ball:QuickObject;
public function Eg2() {
this.sim = new QuickBox2D(this);
this.paddle = this.sim.addBox({
x:13,
y:19,
angle:0,
density:0,
draggable:false,
isBullet:true,
width:8
});
this.ball = this.sim.addPoly({
x:13,
y:1,
restitution:1,
friction:1,
draggable:false,
isBullet:true,
verts:[[-0.34,-1,0.34,-1,0.67,-0.33,0.67,0.33,0.34,1,-0.34,1,-0.67,0.33,-0.67,-0.33]]
});
this.sim.start();
}
}}
示例3来源:
package {
import com.actionsnippet.qbox.QuickBox2D;
import com.actionsnippet.qbox.QuickObject;
import flash.display.MovieClip;
public class Eg3 extends MovieClip {
private var sim:QuickBox2D;
private var paddle:QuickObject;
private var ball:QuickObject;
public function Eg3() {
this.sim = new QuickBox2D(this);
this.paddle = this.sim.addPoly({
x:13,
y:19,
angle:0,
density:0,
draggable:false,
isBullet:true,
verts:[[-3.84,-0.67,-2.84,-1,-2.17,-0.33,2.17,-0.33,2.84,-1,3.84,-0.67,2.84,1,-2.51,1]]
});
this.ball = this.sim.addCircle({
x:13,
y:1,
restitution:1,
friction:1,
draggable:false,
isBullet:true,
radius:1
});
this.sim.start();
}
}}
答案 0 :(得分:0)
是的。我用一组凸起的对象创建了相同的“形状”,它工作得很好。