feat: sprite anchor
This commit is contained in:
parent
d94784e58e
commit
3b6aee099f
|
@ -1,7 +1,7 @@
|
|||
export default (type) => ({
|
||||
export default (type, {x = 0, y = 0} = {}) => ({
|
||||
type: 'object',
|
||||
properties: {
|
||||
x: {type},
|
||||
y: {type},
|
||||
x: {defaultValue: x, type},
|
||||
y: {defaultValue: y, type},
|
||||
},
|
||||
});
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
import vector2d from "./helpers/vector-2d";
|
||||
export default {
|
||||
anchor: vector2d('float32', {x: 0.5, y: 0.5}),
|
||||
animation: {type: 'string'},
|
||||
elapsed: {type: 'float32'},
|
||||
frame: {type: 'uint16'},
|
||||
|
|
|
@ -125,6 +125,7 @@ export default class Engine {
|
|||
VisibleAabb: {},
|
||||
Speed: {speed: 100},
|
||||
Sprite: {
|
||||
anchor: {x: 0.5, y: 0.8},
|
||||
animation: 'moving:down',
|
||||
frame: 0,
|
||||
frames: 8,
|
||||
|
|
|
@ -17,7 +17,7 @@ export default function Sprite({entity}) {
|
|||
}
|
||||
return (
|
||||
<PixiSprite
|
||||
anchor={0.5}
|
||||
anchor={entity.Sprite.anchor}
|
||||
texture={texture}
|
||||
x={Math.round(entity.Position.x)}
|
||||
y={Math.round(entity.Position.y)}
|
||||
|
|
Loading…
Reference in New Issue
Block a user