Jump to content

Calling update function in separate JS file


Draxy
 Share

Recommended Posts

Noob here,

I'm trying to get an update function to call inside a separate JS file. 

I have a basic phaser structure in load.js: 

var myGame = {};
myGame.load = function (game) { };

myGame.load.prototype = {
  preload: function() {
   //..

  },

  create: function(){
   //...

  }

};

myGame.update = function(game) { };

myGame.load.prototype = {
  update: update
};

And the update function I'm trying to add and call in update.js

update = function() {
  game.physics.arcade.collide(blue_player, platforms);
  console.log("update is working");
};

load.js is loaded before update.js in my HTML

Thanks a lot for reading

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

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