fix setting initial sprite size and animation in HTML5

This commit is contained in:
Lizard-13
2015-06-06 19:15:25 -03:00
parent 6173af8574
commit 61fe1a2a2d

View File

@@ -201,10 +201,6 @@ gdjs.SpriteRuntimeObject.thisIsARuntimeObjectConstructor = "Sprite"; //Notify gd
* Initialize the extra parameters that could be set for an instance.
*/
gdjs.SpriteRuntimeObject.prototype.extraInitializationFromInitialInstance = function(initialInstanceData) {
if ( initialInstanceData.customSize ) {
this.setWidth(initialInstanceData.width);
this.setHeight(initialInstanceData.height);
}
if ( initialInstanceData.numberProperties ) {
var that = this;
gdjs.iterateOverArray(initialInstanceData.numberProperties, function(extraData) {
@@ -212,6 +208,10 @@ gdjs.SpriteRuntimeObject.prototype.extraInitializationFromInitialInstance = func
that.setAnimation(extraData.value);
});
}
if ( initialInstanceData.customSize ) {
this.setWidth(initialInstanceData.width);
this.setHeight(initialInstanceData.height);
}
};
/**
@@ -704,12 +704,14 @@ gdjs.SpriteRuntimeObject.prototype.getHeight = function() {
};
gdjs.SpriteRuntimeObject.prototype.setWidth = function(newWidth) {
if ( this._textureDirty ) this._updatePIXITexture();
if ( this._spriteDirty ) this._updatePIXISprite();
var newScaleX = newWidth/this._sprite.texture.frame.width;
this.setScaleX(newScaleX);
};
gdjs.SpriteRuntimeObject.prototype.setHeight = function(newHeight) {
if ( this._textureDirty ) this._updatePIXITexture();
if ( this._spriteDirty ) this._updatePIXISprite();
var newScaleY = newHeight/this._sprite.texture.frame.height;
this.setScaleY(newScaleY);