mirror of
https://github.com/photonstorm/phaser
synced 2025-02-16 05:58:30 +00:00
Working through the Path Manager
This commit is contained in:
parent
302a568566
commit
b141ac468e
3 changed files with 56 additions and 1 deletions
|
@ -1,9 +1,10 @@
|
|||
// Based on the three.js Curve classes created by [zz85](http://www.lab4games.net/zz85/blog)
|
||||
|
||||
var Class = require('../utils/Class');
|
||||
var CubicBezierCurve = require('./curves/cubicbezier/CubicBezierCurve');
|
||||
var GameObjectFactory = require('../scene/plugins/GameObjectFactory');
|
||||
var LineCurve = require('./curves/line/LineCurve');
|
||||
var SplineCurve = require('./curves/spline/SplineCurve');
|
||||
var CubicBezierCurve = require('./curves/cubicbezier/CubicBezierCurve');
|
||||
var Vector2 = require('../math/Vector2');
|
||||
|
||||
// Local cache vars
|
||||
|
@ -17,6 +18,8 @@ var Path = new Class({
|
|||
|
||||
function Path (x, y)
|
||||
{
|
||||
this.name = '';
|
||||
|
||||
this.curves = [];
|
||||
|
||||
this.cacheLengths = [];
|
||||
|
@ -294,8 +297,28 @@ var Path = new Class({
|
|||
}
|
||||
|
||||
return graphics;
|
||||
},
|
||||
|
||||
destroy: function ()
|
||||
{
|
||||
this.curves.length = 0;
|
||||
this.cacheLengths.length = 0;
|
||||
this.startPoint = undefined;
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
// When registering a factory function 'this' refers to the GameObjectFactory context.
|
||||
//
|
||||
// There are several properties available to use:
|
||||
//
|
||||
// this.scene - a reference to the Scene that owns the GameObjectFactory
|
||||
// this.displayList - a reference to the Display List the Scene owns
|
||||
// this.updateList - a reference to the Update List the Scene owns
|
||||
|
||||
GameObjectFactory.register('path', function (x, y)
|
||||
{
|
||||
return new Path(x, y);
|
||||
});
|
||||
|
||||
module.exports = Path;
|
||||
|
|
25
v3/src/paths/local/PathManager.js
Normal file
25
v3/src/paths/local/PathManager.js
Normal file
|
@ -0,0 +1,25 @@
|
|||
var Class = require('../../utils/Class');
|
||||
|
||||
var PathManager = new Class({
|
||||
|
||||
initialize:
|
||||
|
||||
function PathManager (scene)
|
||||
{
|
||||
this.scene = scene;
|
||||
|
||||
this.paths = [];
|
||||
},
|
||||
|
||||
update: function (time, delta)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
// var zigzag = this.add.path(config);
|
||||
// zigzag.release(alien, t);
|
||||
|
||||
|
||||
});
|
||||
|
||||
module.exports = PathManager;
|
|
@ -9,6 +9,7 @@ var GameObjectCreator = require('../plugins/GameObjectCreator');
|
|||
var GameObjectFactory = require('../plugins/GameObjectFactory');
|
||||
var InputManager = require('../plugins/InputManager');
|
||||
var Loader = require('../plugins/Loader');
|
||||
var PathManager = require('../../paths/local/PathManager');
|
||||
var PhysicsManager = require('../plugins/PhysicsManager');
|
||||
var PoolManager = require('../plugins/PoolManager');
|
||||
var SceneManager = require('../plugins/SceneManager');
|
||||
|
@ -53,6 +54,7 @@ var Systems = new Class({
|
|||
this.inputManager;
|
||||
this.load;
|
||||
this.make;
|
||||
this.pathManager;
|
||||
this.physicsManager;
|
||||
this.pool;
|
||||
this.sceneManager;
|
||||
|
@ -85,6 +87,7 @@ var Systems = new Class({
|
|||
this.inputManager = new InputManager(scene);
|
||||
this.load = new Loader(scene);
|
||||
this.make = new GameObjectCreator(scene);
|
||||
this.pathManager = new PathManager(scene);
|
||||
this.physicsManager = new PhysicsManager(scene);
|
||||
this.pool = new PoolManager(scene);
|
||||
this.sceneManager = new SceneManager(scene);
|
||||
|
@ -125,12 +128,16 @@ var Systems = new Class({
|
|||
return;
|
||||
}
|
||||
|
||||
// Move these into local arrays, so you can control which systems are registered here and their
|
||||
// execution order
|
||||
|
||||
this.pool.begin(time);
|
||||
this.updateList.begin(time);
|
||||
this.time.begin(time);
|
||||
this.tweens.begin(time);
|
||||
this.inputManager.begin(time);
|
||||
|
||||
this.pathManager.update(time, delta);
|
||||
this.physicsManager.update(time, delta);
|
||||
|
||||
this.pool.update(time, delta);
|
||||
|
|
Loading…
Add table
Reference in a new issue