找回密码
 立即注册
搜索
热搜: 活动 交友 discuz
查看: 69|回复: 5

你们看一下

[复制链接]

31

主题

101

回帖

523

积分

老猫

积分
523
发表于 2024-8-23 12:03:54 | 显示全部楼层 |阅读模式

var walk = qc.defineBehaviour('qc.engine.walk', qc.Behaviour, function() {
    // need this behaviour be scheduled in editor
    //this.runInEditor = true;
    this.zy = 0,
    this.zx = 0,
    this.speed = 0,
    this.f = '上',
    this.time = 0,
    this.time2 = 0
}, {
    开始xy: qc.Serializer.POINT,
    结束xy: qc.Serializer.POINT,
    速度: qc.Serializer.NUMBER,
    时间1: qc.Serializer.NUMBER,
    方向: qc.Serializer.NUMBER,
    时间2: qc.Serializer.NUMBER
    // fields need to be serialized
});
walk.prototype.update = function(){
    this.anchoredX = this.x
    this.anchoredY = this.y
    switch(this.f){
        case '上':
            this.s()
            break;
        case '下':
            this.x()
            break;
        case '左':
            this.z()
            break;
        case '右':
            this.y()
            break;
        case '左右':
            this.zy()
            break;
        case '上下':
            this.sx()
            break;
        default:
            return;
    }
},
walk.prototype.s = function(){
    while(this.anchoredY > this.zy){
        this.anchoredY -= this.speed
    }
    setTimeout(() => {
        this.anchoredY = this.y
        this.s()
    }, this.time);
},
walk.prototype.x = function(){
    while(this.anchoredY < this.zy){
        this.anchoredY += this.speed
    }
    setTimeout(() => {
        this.anchoredY = this.y
        this.x()
    }, this.time);
},
walk.prototype.z = function(){
    while(this.anchoredX > this.zx){
        this.anchoredX -= this.speed
    }
    setTimeout(() => {
        this.anchoredX = this.x
        this.z()
    }, this.time);
},
walk.prototype.y = function(){
    while(this.anchoredX < this.zx){
        this.anchoredX += this.speed
    }
    setTimeout(() => {
        this.anchoredX = this.x
        this.y()
    }, this.time);
},
walk.prototype.sx = function(){
    while(this.anchoredY > this.zy){
        this.anchoredY -= this.speed
    }
    setTimeout(() => {
        while(this.anchoredY < this.zy){
            this.anchoredY += this.speed
        }
        setTimeout(() => {
            this.sx()
        }, this.time);
    }, this.time2);
},
walk.prototype.zy = function(){
    while(this.anchoredX > this.zx){
        this.anchoredX -= this.speed
    }
    setTimeout(() => {
        while(this.anchoredX < this.zx){
            this.anchoredX += this.speed
        }
        setTimeout(() => {
            this.zy()
        }, this.time);
    }, this.time2);
};
//Called when the script instance is being loaded.
//walk.prototype.awake = function() {
//
//};

// Called every frame, if the behaviour is enabled.
//walk.prototype.update = function() {
//
//};



回复

使用道具 举报

发表于 2024-8-23 12:10:41 | 显示全部楼层
这是什么                     

点评

qici代码  发表于 2024-8-23 12:11
黄鹤一去不复返,白云千载空悠悠
回复

使用道具 举报

发表于 2024-8-23 12:11:29 | 显示全部楼层
我运行试试看
回复

使用道具 举报

发表于 2024-8-23 12:13:51 | 显示全部楼层
干什么用的代码,我问的是这个,说我能听懂的
黄鹤一去不复返,白云千载空悠悠
回复

使用道具 举报

发表于 2024-8-23 12:34:12 | 显示全部楼层
怎么不说话了
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

Archiver|手机版|小黑屋|WTFBBS

GMT+8, 2024-10-25 07:30 , Processed in 0.085808 second(s), 21 queries .

Powered by Discuz! X3.5

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表