mirror of
https://github.com/wassname/phaser.git
synced 2026-07-04 17:20:31 +08:00
Started revamp of the Tilemap system. Also removed old 'Advanced Physics' and dropped in p2.js which is what I hope we'll eventually use.
This commit is contained in:
@@ -0,0 +1,65 @@
|
||||
var Utils = require('../utils/Utils');
|
||||
|
||||
module.exports = Solver;
|
||||
|
||||
/**
|
||||
* Base class for constraint solvers.
|
||||
* @class Solver
|
||||
* @constructor
|
||||
*/
|
||||
function Solver(){
|
||||
|
||||
/**
|
||||
* Current equations in the solver.
|
||||
*
|
||||
* @property equations
|
||||
* @type {Array}
|
||||
*/
|
||||
this.equations = [];
|
||||
};
|
||||
|
||||
Solver.prototype.solve = function(dt,world){
|
||||
throw new Error("Solver.solve should be implemented by subclasses!");
|
||||
};
|
||||
|
||||
/**
|
||||
* Add an equation to be solved.
|
||||
*
|
||||
* @method addEquation
|
||||
* @param {Equation} eq
|
||||
*/
|
||||
Solver.prototype.addEquation = function(eq){
|
||||
this.equations.push(eq);
|
||||
};
|
||||
|
||||
/**
|
||||
* Add equations. Same as .addEquation, but this time the argument is an array of Equations
|
||||
*
|
||||
* @method addEquations
|
||||
* @param {Array} eqs
|
||||
*/
|
||||
Solver.prototype.addEquations = function(eqs){
|
||||
Utils.appendArray(this.equations,eqs);
|
||||
};
|
||||
|
||||
/**
|
||||
* Remove an equation.
|
||||
*
|
||||
* @method removeEquation
|
||||
* @param {Equation} eq
|
||||
*/
|
||||
Solver.prototype.removeEquation = function(eq){
|
||||
var i = this.equations.indexOf(eq);
|
||||
if(i!=-1)
|
||||
this.equations.splice(i,1);
|
||||
};
|
||||
|
||||
/**
|
||||
* Remove all currently added equations.
|
||||
*
|
||||
* @method removeAllEquations
|
||||
*/
|
||||
Solver.prototype.removeAllEquations = function(){
|
||||
this.equations.length=0;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user