地图修改
This commit is contained in:
@@ -1,16 +1,22 @@
|
||||
import { _decorator, Component, Node } from 'cc';
|
||||
import { _decorator, CCInteger, Component, Node } from 'cc';
|
||||
const { ccclass, property } = _decorator;
|
||||
|
||||
@ccclass('move')
|
||||
export class move extends Component {
|
||||
@property({ type: CCInteger })
|
||||
speed:number=2
|
||||
@property({ type: CCInteger })
|
||||
maxX:number=640
|
||||
@property({ type: CCInteger })
|
||||
minX:number=-640
|
||||
start() {
|
||||
|
||||
}
|
||||
|
||||
update(dt: number) {
|
||||
this.node.setPosition(this.node.position.x+dt*15,this.node.position.y)
|
||||
if(this.node.position.x >= 1700){
|
||||
this.node.setPosition(-1700,this.node.position.y)
|
||||
this.node.setPosition(this.node.position.x+dt*this.speed,this.node.position.y)
|
||||
if(this.node.position.x >= this.maxX){
|
||||
this.node.setPosition(this.minX,this.node.position.y)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user