Closed elijah-t closed 4 years ago
Let's give an example of what the datastructure for the spritestate object would look like. maybe something like this?
export default {
properties: {},
states: {
idle: {
location: '/' + require('./assets/goku_idle.png').default, //location of sprites
rps: 5, //refresh per second
loop: true, //will continue to loop
frames: [{
x: 3,
y: 3,
width: 48,
height: 85
}, {
x: 55,
y: 3,
width: 46,
height: 86
}, {
x: 103,
y: 0,
width: 45,
height: 91
}]
},
fight: {
location: '/' + require('./assets/goku_fight.png').default, //location of sprites
rps: 10, //refresh per second
frames: [{
x: 0,
y: 9,
width: 59,
height: 78
}, {
x: 69,
y: 10,
width: 87,
height: 77
}, {
x: 164,
y: 0,
width: 51,
height: 88
}, {
x: 226,
y: 1,
width: 80,
height: 89
}]
}
}
}
Yeah, the structure of the sprite state object would look similar to that I would imagine.
what would the spriteActor class look like?
resolved in #17
Sprite states / animations
Sprites will have different animations paired with different states, as well as a fallback animation for default states (idle).
TODO:
Constructor e.g.
constructor(sprite, state)
Create functions to set/get states in sprite objects: e.g.
setState(state, animation)
getState();
Have an optional fallback state if no animation is set for a state