九月28的项目

flabby_bird






地板运动逻辑:
1. 两个底板都以每0.05秒香左5像素移动,即:
ground.x +=move_speed:
2一旦某一底板离开屏幕显示范围,就将其位置立即放到另一地板后


帧动画循环


图片规律123456


放置规律1234565432完成循环
地板向下移动代码
cc.Class({
    extends: cc.Component,


    properties: {
        //地板的移动速度
        move_speed: -5,
        //地板移动的时间间隔
        move_interval: 0.05,
        // 地板节点数组
        groundNode: {
            default: [],
            type: [cc.Node]
        },
        // 地板图片对象
        groundImg: {
            default: null,
            type: cc.Sprite
        },
    },


    // use this for initialization
    onLoad: function () {
        // 获取屏幕尺寸
        this._size = cc.winSize;
        // 获取地板图片的宽度
        this._height = this.groundImg.spriteFrame.getRect().height;
        // 启动“地板移动控制”计时器
        this.schedule(this.onGroundMove, this.move_interval);


    },


    onGroundMove: function() {
        this.groundNode[0].y += this.move_speed;
        this.groundNode[1].y += this.move_speed;
        if (this.groundNode[0].y + this._height/2 < - this._size.height/2) {
            this.groundNode[0].y = this.groundNode[1].y + this._height - 16;
        }
        if (this.groundNode[1].y + this._height/2 < - this._size.height/2) {
            this.groundNode[1].y = this.groundNode[0].y + this._height - 16;
        }
  },
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值