feat: animation offset
This commit is contained in:
parent
fff621be50
commit
7902311131
|
@ -54,7 +54,7 @@ class AnimatedBase extends Trait {
|
|||
const animationPromises = [];
|
||||
// Load all animations.
|
||||
for (const key in animations) {
|
||||
const uri = animations[key];
|
||||
const {uri} = animations[key];
|
||||
const promise = Animation.load(uri).then((animation) => {
|
||||
// Zip with key to make populating animations and views trivial.
|
||||
return {animation, key};
|
||||
|
@ -109,10 +109,12 @@ class AnimatedBase extends Trait {
|
|||
if (!animationView) {
|
||||
return;
|
||||
}
|
||||
const animations = this.params.get('animations');
|
||||
const {offset} = animations[key];
|
||||
const {animation} = animationView;
|
||||
const size = Rectangle.size(animation.sourceRectangle)
|
||||
const offset = Vector.scale(size, -0.5);
|
||||
animationView.position = offset;
|
||||
const halfway = Vector.scale(size, -0.5);
|
||||
animationView.position = Vector.add(halfway, offset);
|
||||
this.entity.container.addChild(animationView);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user