PictureBox = {
new : function (srcBitmap,x,y,width,height, type) {
var that = this;
this
.attr_accessor('bitmap', function(){that.createSprite(that)})
.attr_accessor('x', function() {that.sprite.x = that._x})
.attr_accessor('y', function() {that.sprite.y = that._y})
.attr_accessor('width', function(){that.createSprite(that)})
.attr_accessor('height', function(){that.createSprite(that)})
.attr_accessor('type', function(){that.createSprite(that)});
this._bitmap = srcBitmap;
this._x = x || 0;
this._y = y || 0;
this._width = width || 0;
this._height = height || 0;
this._type = type || 0;
this.sprite = new Sprite(this._bitmap);
this.sprite.x = this._x;
this.sprite.y = this._y;
this.createSprite(that);
return this;
},
createSprite: function (that) {
if(that._type === 0) {
that.sprite.width = that._width;
that.sprite.height = that._height;
} else if (that._type === 1) {
var x = that._width / that.sprite.width;
var y = that._height / that.sprite.height;
that.sprite.scale = new Point(x,y);
that.sprite.x = that._x;
that.sprite.y = that._y;
}
},
setType : function (type) {
this._type = type;
this.createSprite(this);
},
update : function () {}
}
试了下直接基于原型的写法,蛮有趣的
开了一个坑。这是其中一部分【还有个Button是按伪类继承,而且是直接继承Sprite。。。打算重写】
计划中的还有一个InputBox和ProgressBar
并不能算是GUI 只是简单的显示容器和特定的方法的封装
至于GUI的坑。。。估计得等到魔改完MV了
顺便吐槽一句 MV简直神坑