Project-Rekt / engine

Game Engine - Currently on version MASON
https://project-rekt.github.io/engine/index.html
Apache License 2.0
1 stars 3 forks source link

Create SpriteActor class #17

Closed elijah-t closed 4 years ago

elijah-t commented 4 years ago

A defined schema is needed for sprite objects

The SpriteActor class will have defined properties and defined file structure (for frames/sprite sheets on export).

Example code:

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
            }]
        }
    }
}
Squishy123 commented 4 years ago

Make sure you make it a class that inherits from actor and has image loading abilities