Jimmy Posted December 30, 2014 Share Posted December 30, 2014 Hi,I'm trying to get used to how Phaser really works and I've know got a small question. I've structured my game state as following:var myGame = myGame || {};myGame.Game = function(){};myGame.Game.prototype = { create: function() { }, update: function() { }}; I removed the actual code that's inside as I don't think I need to show it. Now I'm at the state where I want to create a AI sprite object. There will be a lot of these "AI bots" and I'll put them in a group. Though the AI entity/object are going to have quite many variables as well as functions assigned to it. Imagine something like the "EnemyTank" in the tanks example found here: http://examples.phaser.io/_site/view_full.html?d=games&f=tanks.js&t=tanks Now my question is how you would go ahead and create this AI object? Is it a wise decision to structure and place it as in the Tanks example or would you personally prefer to write an other way? I'm mainly just looking for some advice of what's the best practice really. Because often when working on projects I start out thinking that I don't need to worry much about how I structure my code but as the projects grow you always regret that you didn't put more effort into structuring your code properly. Link to comment Share on other sites More sharing options...
CtlAltDel Posted December 31, 2014 Share Posted December 31, 2014 This url should give you one example of structuring. http://www.codevinsky.com/phaser-2-0-tutorial-flappy-bird-part-1/ There are of course other ways to accomplish code structure. Link to comment Share on other sites More sharing options...
Jimmy Posted December 31, 2014 Author Share Posted December 31, 2014 Thanks! The prefab instructions in part 2 was was really great for me. Think I'll go with that method. Link to comment Share on other sites More sharing options...
Recommended Posts