You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm trying to match the size of an animation with the actor size. I'm sure I just miss something, but I don't get at what step.
So I created a class Player like that :
import{Actor,Engine,Input,SpriteSheet}from"excalibur";import{Resources}from"../resources";exportclassPlayerActorextendsActor{constructor(x,y){super(x,y,120,120);}publiconInitialize(engine: Engine): void{// create a SpriteSheet for the animationsuper.onInitialize(engine);constplayerSheet=newSpriteSheet(Resources.Player,8,1,1068.5,927);constplayerWait=newSpriteSheet(Resources.PlayerWait,17,1,1086.882352941176,912);// create an animationconstplayerAnimation=playerSheet.getAnimationForAll(engine,100);playerAnimation.loop=true;playerAnimation.scale.setTo(2,2);this.addDrawing("move",playerAnimation);constnotMoveAnimation=playerWait.getAnimationForAll(engine,60);notMoveAnimation.loop=false;notMoveAnimation.scale.setTo(2,2);this.addDrawing("notMove",notMoveAnimation);this.setDrawing("notMove");}publicupdate(engine: Engine,delta: number): void{super.update(engine,delta);this.move(engine);}privatemove(engine: Engine): void{if(engine.input.keyboard.isHeld(Input.Keys.Right)){this.setDrawing("move");this.moveBackward();return;}if(engine.input.keyboard.isHeld(Input.Keys.Left)){this.setDrawing("move");this.moveForward();return;}this.setDrawing("notMove");}privatemoveForward(){this.pos.x=this.pos.x-1;}privatemoveBackward(){this.pos.x=this.pos.x+1;}}
As you can see, My sprite is quite huge. I just would like to re size it according to the size of the actual player.
Can you tell me how I can achieve it ?
Thanks by advance.
By the way, I'm using the last version of Excalibur (v0.23.0)
This discussion was converted from issue #1240 on October 17, 2020 02:40.
Heading
Bold
Italic
Quote
Code
Link
Numbered list
Unordered list
Task list
Attach files
Mention
Reference
Menu
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Hello,
I'm trying to match the size of an animation with the actor size. I'm sure I just miss something, but I don't get at what step.
So I created a class Player like that :
As you can see, My sprite is quite huge. I just would like to re size it according to the size of the actual player.
Can you tell me how I can achieve it ?
Thanks by advance.
By the way, I'm using the last version of Excalibur (v0.23.0)
Beta Was this translation helpful? Give feedback.
All reactions