[]我用as3调试的matter.js,刚体发生碰撞后不会旋转,我的代码在附件里
我用as3、FlashDevelop调试的matter.js,
laya版本1.7.8,
matter.js版本0.13.0
刚体发生碰撞后不会旋转,
我的代码在附件里
laya版本1.7.8,
matter.js版本0.13.0
刚体发生碰撞后不会旋转,
我的代码在附件里
没有找到相关结果
已邀请:
要回复问题请先登录
3 个回复
cuixueying
赞同来自:
layazzzooovvv
赞同来自:
{
import data.Manager;
import laya.display.Sprite;
import laya.display.Stage;
import laya.net.Loader;
import laya.renders.Render;
import laya.utils.Browser;
import laya.utils.Handler;
import laya.utils.Stat;
import laya.webgl.WebGL;
import wawaji.Wawaji;
/**
* ...
* @author zzz
*/
public class WWJ_Main
{
private const stageWidth:int = 540;
private const stageHeight:int = 960;
private var Matter:Object = Browser.window.Matter;
private var LayaRender:Object = Browser.window.LayaRender;
private var mouseConstraint:*;
private var engine:*;
private var t_obj:Object;
private var url_img:String = "res/";
public function WWJ_Main()
{
Laya.init(stageWidth, stageHeight);
Laya.stage.alignV = Stage.ALIGN_MIDDLE;
Laya.stage.alignH = Stage.ALIGN_CENTER;
Laya.stage.scaleMode = "showall";
Laya.stage.bgColor = "#ffffff";
Stat.show();
setup();
}
private function setup():void
{
initMatter();
initWorld();
}
private function initMatter():void
{
// 初始化物理引擎
engine = Matter.Engine.create({enableSleeping: true});
Matter.Engine.run(engine);
var render = LayaRender.create({engine: engine, width: 800, height: 600,
options: {
background: url_img + 'img/background.png',
enabled: true,
wireframes: false,
showSleeping: true,
showDebug: false,
showBroadphase: false,
showBounds: false,
showVelocity: false,
showCollisions: false,
showSeparations: false,
showAxes: false,
showPositions: false,
showAngleIndicator: false,
showIds: false,
showShadows: false,
showVertexNumbers: false,
showConvexHulls: false,
showInternalEdges: false,
showMousePosition: false
}});
LayaRender.run(render);
}
private var rock:Object;
private function initWorld():void
{
var ground1:* = Matter.Bodies.rectangle(500, 0, 1000, 20, {isStatic: true, render: {fillStyle: '#edc51e', strokeStyle: '#b5a91c'}});
var ground2:* = Matter.Bodies.rectangle(0, 500, 20, 1000, {isStatic: true, render: {fillStyle: '#edc51e', strokeStyle: '#b5a91c'}});
var ground3:* = Matter.Bodies.rectangle(500, 700, 1000, 20, {isStatic: true, render: {fillStyle: '#edc51e', strokeStyle: '#b5a91c'}});
var ground4:* = Matter.Bodies.rectangle(400, 500, 20, 1000, {isStatic: true, render: {fillStyle: '#edc51e', strokeStyle: '#b5a91c'}});
engine.world.gravity.y = 2;
Matter.World.add(engine.world, [ ground1,ground2,ground3,ground4]);
Laya.timer.loop(1000, this, add_F);
}
private function add_F():void
{
var rockOptions:Object = {
stiffness: 1,
friction: 1,
restitution: 0.8,
//angularSpeed:0.1,//角速度
//restitution:1,//弹性
//density: 0.004//密度
};
var rock_:Object = Matter.Bodies.polygon(Math.random()*100+100, 50, 3, 30, rockOptions);
Matter.World.add(engine.world, [ rock_]);
}
}
}
layazzzooovvv
赞同来自:
用IDE1.7.8
代码在附件里