cbbandtqb 0 Posted December 8, 2020 Report Share Posted December 8, 2020 Hi, I have a beginner's question about melonjs. If I run '<any sprite object>.scale(2);', then the sprite will move a little to the upper left on the screen, and the sprite's appearance will be about four times as large. The anchorPoint of the sprite is (0.5,0.5)(=default), so I think the sprite can't move, it just doubles the size of the sprite, but what's wrong with my code? My environment is melonjs 8.0.1, browser is chrome, OS is macOS High sierra. Thank you. Quote Link to post Share on other sites
cbbandtqb 0 Posted December 8, 2020 Author Report Share Posted December 8, 2020 I have one more report. If I write {anchorPoint:(0.5, 0.5)} in 'init' explicitly, then the application freeze. Why? Quote Link to post Share on other sites
obiot 40 Posted January 11 Report Share Posted January 11 hi, can you copy paste the part of the code doing the scaling here just to be sure ? also is this on a me.Sprite object ? or for/in a an Entity ? Quote Link to post Share on other sites
cbbandtqb 0 Posted January 17 Author Report Share Posted January 17 Thank you for your replying. My code is below. This is on a me.Sprite, not for/in an Entity. <play.js> StretchingSprite = me.Sprite.extend({ init : function(sx, sy, sc) { this._super(me.Sprite, 'init', [sx*chrX+chrX/2, sy*chrY+chrY/2, {image:chr[sc]}]); this.tm = 1; this.itv = 0; }, update : function(dt) { this.itv += dt; if (this.itv < 100) { return true; } this.itv = 0; this.tm -= 0.2; if (this.tm < 1) { if (this.tm < 0) { this.tm = 0; } this.alpha = this.tm; this.scale(2-this.tm); } if (this.tm <= 0) { me.game.world.removeChild(this); } return true; } }); Quote Link to post Share on other sites
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.