-
Creator 版本:3.8.5
-
目标平台:测试平台Chrome
(十分重要,别简单的就说“原生”或者“网页”)–> -
重现方式:滚动时偶尔会出现
-
首个报错:控制台没报错
项目设置 720 * 1280 适配高度
两种背景图 720 * 1280
适配设计分辨率或者不同手机型号会出现闪烁线条或者两图之间有空隙
尝试过 ± 2/3 但也会出现
估计时update的y不是整数,当速度快的时候明显
望各位大哥给给解决方案~ 谢谢
import { _decorator, Component, Node, Size, UITransform, view } from ‘cc’;
const { ccclass, property } = _decorator;
@ccclass(‘bg_controller’)
export class bg_controller extends Component {
public speed:number = 200;
public sw:number = 0
public sh:number = 0
start() {
// const screen = view.getVisibleSize()
// this.sw = screen.width
// this.sh = screen.height
// for(let nodes of this.node.children){
// let bgUITransform = nodes.getComponent(UITransform)
// // bgUITransform.setContentSize(new Size(bgUITransform.contentSize.x, this.sh))
// nodes.setScale(nodes.scale.x, this.sh/bgUITransform.height)
// }
}
update(deltaTime: number) {
const bgNodes = this.node.children
bgNodes.forEach((bgNode)=>{
bgNode.setPosition(bgNode.position.x, bgNode.position.y + this.speed*deltaTime)
if(bgNode.position.y >= 1278){
bgNode.setPosition(bgNode.position.x, -1280)
}
})
}
}
