注册会员 登录
Project1 返回首页

汪汪的个人空间 https://rpg.blue/?171386 [收藏] [复制] [分享] [RSS]

日志

【小白】机翻注释mv的 Sprite_Base

已有 68 次阅读2015-11-4 20:25 |个人分类:mv: rpg_sprites


//-----------------------------------------------------------------------------
// Sprite_Base
// 基础精灵
// The sprite class with a feature which displays animations.
// 显示一个动画特征的精灵类

function Sprite_Base() {
    this.initialize.apply(this, arguments);
}

Sprite_Base.prototype = Object.create(Sprite.prototype);
Sprite_Base.prototype.constructor = Sprite_Base;
//初始化
Sprite_Base.prototype.initialize = function() {
    Sprite.prototype.initialize.call(this);
    this._animationSprites = [];
    this._effectTarget = this;
    this._hiding = false;
};
//更新
Sprite_Base.prototype.update = function() {
    Sprite.prototype.update.call(this);
    this.updateVisibility();
    this.updateAnimationSprites();
};
//隐藏
Sprite_Base.prototype.hide = function() {
    this._hiding = true;
    this.updateVisibility();
};
//显示
Sprite_Base.prototype.show = function() {
    this._hiding = false;
    this.updateVisibility();
};
//更新可见度
Sprite_Base.prototype.updateVisibility = function() {
    this.visible = !this._hiding;
};
//更新动画精灵
Sprite_Base.prototype.updateAnimationSprites = function() {
    if (this._animationSprites.length > 0) {
        var sprites = this._animationSprites.clone();
        this._animationSprites = [];
        for (var i = 0; i < sprites.length; i++) {
            var sprite = sprites[i];
            if (sprite.isPlaying()) {
                this._animationSprites.push(sprite);
            } else {
                sprite.remove();
            }
        }
    }
};
//开始动画
Sprite_Base.prototype.startAnimation = function(animation, mirror, delay) {
    var sprite = new Sprite_Animation();
    sprite.setup(this._effectTarget, animation, mirror, delay);
    this.parent.addChild(sprite);
    this._animationSprites.push(sprite);
};
//是动画播放中
Sprite_Base.prototype.isAnimationPlaying = function() {
    return this._animationSprites.length > 0;
};


鸡蛋

鲜花

评论 (0 个评论)

facelist doodle 涂鸦笔

您需要登录后才可以评论 登录 | 注册会员

拿上你的纸笔,建造一个属于你的梦想世界,加入吧。
 注册会员
找回密码

站长信箱:[email protected]|手机版|小黑屋|无图版|Project1游戏制作

GMT+8, 2024-5-10 20:29

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

返回顶部