[]物理Bodies绑定Laya.Sprite
Laya.init(600, 400, Laya.WebGL); // 初始化一个画布,使用 WebGL 渲染,不支持时会自动切换为 Canvas
Laya.stage.alignV = 'top'; // 适配垂直对齐方式
Laya.stage.alignH = 'middle'; // 适配水平对齐方式
Laya.stage.screenMode = this.Stage.SCREEN_HORIZONTAL; // 始终以横屏展示
Laya.stage.scaleMode = "fixedwidth"; // 宽度不变
this.engine;
var world;
this.engine = Matter.Engine.create({
enableSleeping: true // 开启睡眠
});
world = this.engine.world;
Matter.Engine.run(this.engine); // Engine 启动
var render = LayaRender.create({
engine: this.engine,
options: { wireframes: false, background: "#000" }
});
LayaRender.run(render); // Render 启动
var gun_skin = new Laya.Sprite().loadImage("images/qiang_001.png");
gun_skin.scale(50, 50);
gun_skin.pivot(gun_skin.width / 2, gun_skin.height / 2);
gun = Bodies.rectangle(150, 150, 50, 50, {
frictionAir: 0.5, //空气摩擦力
density: 0.68, // 密度
layaSprite: gun_skin, // 绑定一个laya的Sprite, 不能用render.sprite
render: {
visible: true, // 开启渲染
}
});
console.log("增加刚体...");
World.add(world, gun);
点击运行之后,屏幕都是黑色,不显示图片信息。这个感觉是有问题,还请官方来回答,非常感谢!!
Laya.stage.alignV = 'top'; // 适配垂直对齐方式
Laya.stage.alignH = 'middle'; // 适配水平对齐方式
Laya.stage.screenMode = this.Stage.SCREEN_HORIZONTAL; // 始终以横屏展示
Laya.stage.scaleMode = "fixedwidth"; // 宽度不变
this.engine;
var world;
this.engine = Matter.Engine.create({
enableSleeping: true // 开启睡眠
});
world = this.engine.world;
Matter.Engine.run(this.engine); // Engine 启动
var render = LayaRender.create({
engine: this.engine,
options: { wireframes: false, background: "#000" }
});
LayaRender.run(render); // Render 启动
var gun_skin = new Laya.Sprite().loadImage("images/qiang_001.png");
gun_skin.scale(50, 50);
gun_skin.pivot(gun_skin.width / 2, gun_skin.height / 2);
gun = Bodies.rectangle(150, 150, 50, 50, {
frictionAir: 0.5, //空气摩擦力
density: 0.68, // 密度
layaSprite: gun_skin, // 绑定一个laya的Sprite, 不能用render.sprite
render: {
visible: true, // 开启渲染
}
});
console.log("增加刚体...");
World.add(world, gun);
点击运行之后,屏幕都是黑色,不显示图片信息。这个感觉是有问题,还请官方来回答,非常感谢!!
没有找到相关结果
已邀请:
要回复问题请先登录
2 个回复
w1114367261
赞同来自:
(^_^)
赞同来自: