react-game-engine
Advanced tools
Comparing version 1.1.0 to 1.2.0
@@ -335,11 +335,12 @@ module.exports = | ||
var newState = _this.props.systems.reduce(function (state, sys) { | ||
return sys(state, args); | ||
}, _this.state.entities); | ||
_this.input.length = 0; | ||
_this.events.length = 0; | ||
_this.previousTime = currentTime; | ||
_this.previousDelta = args.time.delta; | ||
_this.setState({ entities: newState }); | ||
_this.setState(function (prevState) { | ||
var newEntities = _this.props.systems.reduce(function (state, sys) { | ||
return sys(state, args); | ||
}, prevState.entities); | ||
_this.input.length = 0; | ||
_this.events.length = 0; | ||
_this.previousTime = currentTime; | ||
_this.previousDelta = args.time.delta; | ||
return { entities: newEntities }; | ||
}); | ||
}; | ||
@@ -364,3 +365,2 @@ | ||
_this.timer = props.timer || new _DefaultTimer2.default(); | ||
_this.timer.subscribe(_this.updateHandler); | ||
_this.input = []; | ||
@@ -385,16 +385,18 @@ _this.previousTime = null; | ||
case 0: | ||
this.timer.subscribe(this.updateHandler); | ||
entities = getEntitiesFromProps(this.props); | ||
if (!isPromise(entities)) { | ||
_context2.next = 5; | ||
_context2.next = 6; | ||
break; | ||
} | ||
_context2.next = 4; | ||
_context2.next = 5; | ||
return entities; | ||
case 4: | ||
case 5: | ||
entities = _context2.sent; | ||
case 5: | ||
case 6: | ||
@@ -407,3 +409,3 @@ this.setState({ | ||
case 6: | ||
case 7: | ||
case "end": | ||
@@ -558,3 +560,2 @@ return _context2.stop(); | ||
_this.timer = props.timer || new _DefaultTimer2.default(); | ||
_this.timer.subscribe(_this.updateHandler); | ||
_this.input = []; | ||
@@ -570,2 +571,4 @@ _this.previousTime = null; | ||
value: function componentDidMount() { | ||
this.timer.subscribe(this.updateHandler); | ||
if (this.props.running) this.start(); | ||
@@ -572,0 +575,0 @@ } |
{ | ||
"name": "react-game-engine", | ||
"version": "1.1.0", | ||
"version": "1.2.0", | ||
"description": "A lightweight game engine for React projects", | ||
@@ -5,0 +5,0 @@ "main": "build/index.js", |
40006
528