Jump to content

one character multiple code files


elad
 Share

Recommended Posts

Is there a way to create sprite from multiple files ? 

Like creating a sprite : Knight in 'knight.js'

and creating his movement in 'movement.js'

is this possible :

 


// knight.js

import Phaser from 'phaser'
import Movement from './movement'

export default class extends Phaser.Sprite {
    constructor ({ game, x, y, asset }) {
    super(game, x, y, asset)
 }
  movement(){
    // Here Ill call Movement 
  }
}


// movement.js
import Phaser from 'phaser'

export default class extends Phaser.Sprite {
  
  // Here ill make a function that will move the sprite
  // and start the animation
}

 

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...