你的浏览器禁用了JavaScript, 请开启后刷新浏览器获得更好的体验!
输入关键字进行搜索
搜索:
发现
话题
全文搜索
登录
[0]Box2D项目滚动屏幕问题
想实现超级玛丽那样角色始终在屏幕中间,滚动背景世界
发现无论是方法1还是方法2都不行....
Test.rar
没有找到相关结果
已邀请:
与内容相关的链接
提交
2 个回复
Winterning
赞同来自:
DEMO点击屏幕就是给主角加个力 往右边移动的 移动到中场就开始滚屏 结果跟预想不太一样...
Winterning
赞同来自:
private watch(): void {
//方法1:移动父容器
// var gloX = -this.player.x + GameConfig.width * 0.5;
// if (gloX > 0) {
// gloX = 0;
// }
// else if (gloX < -MainSceneCtrl.SCENE_WIDTH + GameConfig.width) {
// gloX = -MainSceneCtrl.SCENE_WIDTH + GameConfig.width;
// }
// this.mainScene.world.x = gloX;
// console.log("@@gloX="+gloX);
//方法2:scrollRect
var tx = this.player.x - GameConfig.width * 0.5;
if (tx < 0) {
tx = 0;
}
else if (tx > MainSceneCtrl.SCENE_WIDTH - GameConfig.width) {
tx = MainSceneCtrl.SCENE_WIDTH - GameConfig.width;
}
this.mainScene.world.scrollRect = new Laya.Rectangle(tx, 0, GameConfig.width, GameConfig.height);
console.log("@@tx="+tx);
}
要回复问题请先
登录
发起人
Winterning
相关问题
laya针对页游耗用内存大的问题是如何解决的?
【屏幕适配】在LayaAir上面是竖屏,为什么到微信开发工具中就是横屏,而且还被拉伸了
TS项目使用matter.js库无智能提示
Laya2.12.0项目出现卡顿现象(必现)
layaair3.1.3版本打出的项目中的text与label组件在vivo小游戏引擎1105及以下文字显示异常
Laya2.0项目文件过多导致编译内存不够,请问在哪里设置增加编译内存(急)
layaAir TS项目如何引用protoBuf库?
屏幕适配怎样实现铺满全屏,又不被拉伸?
用了第三方socket类 项目在IDE上可以连接正常运行,为什么打包APK之后在手机上就连接不上socket
如何通过命令行工具构建和发布项目
将list里的scrollBar设置mouseWheelEnable=false后过一段时间设置mouseWheelEnable=true;无法滚动
问题状态
最新活动:
2021-12-22 18:51
浏览:
838
关注:
1
人
商务合作
2 个回复
Winterning
赞同来自:
Winterning
赞同来自:
//方法1:移动父容器
// var gloX = -this.player.x + GameConfig.width * 0.5;
// if (gloX > 0) {
// gloX = 0;
// }
// else if (gloX < -MainSceneCtrl.SCENE_WIDTH + GameConfig.width) {
// gloX = -MainSceneCtrl.SCENE_WIDTH + GameConfig.width;
// }
// this.mainScene.world.x = gloX;
// console.log("@@gloX="+gloX);
//方法2:scrollRect
var tx = this.player.x - GameConfig.width * 0.5;
if (tx < 0) {
tx = 0;
}
else if (tx > MainSceneCtrl.SCENE_WIDTH - GameConfig.width) {
tx = MainSceneCtrl.SCENE_WIDTH - GameConfig.width;
}
this.mainScene.world.scrollRect = new Laya.Rectangle(tx, 0, GameConfig.width, GameConfig.height);
console.log("@@tx="+tx);
}