Skip to content

Commit

Permalink
added isRunning function
Browse files Browse the repository at this point in the history
  • Loading branch information
cemerick committed May 4, 2011
1 parent f3095f5 commit b2b57a8
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 7 deletions.
24 changes: 18 additions & 6 deletions src/kernel.js
Expand Up @@ -25,6 +25,7 @@
var _tickInterval = null
var _lastTick = null
var _paused = false
var _running = false

var that = {
system:pSystem,
Expand Down Expand Up @@ -98,11 +99,15 @@
},

workerMsg:function(e){
var type = e.data.type
if (type=='geometry'){
that.workerUpdate(e.data)
}else{
trace('physics:',e.data)
switch (e.data.type) {
case 'geometry':
that.workerUpdate(e.data)
break
case 'stopping':
_running = false
break
default:
trace('physics:',e.data)
}
},
_lastPositions:null,
Expand Down Expand Up @@ -184,6 +189,7 @@
// trace('stopping')
clearInterval(_tickInterval)
_tickInterval = null
_running = false;
}else{
// trace('pausing')
}
Expand Down Expand Up @@ -222,6 +228,8 @@
_tickInterval = setInterval(that.physicsUpdate,
that.system.parameters().timeout)
}

_running = true
},
stop:function(){
_paused = true
Expand All @@ -233,7 +241,11 @@
_tickInterval = null
}
}


_running = false;
},
isRunning:function() {
return _running;
}
}

Expand Down
3 changes: 3 additions & 0 deletions src/physics/system.js
Expand Up @@ -75,6 +75,9 @@
stop:function(){
state.kernel.stop()
},
isRunning:function(){
return state.kernel.isRunning()
},

addNode:function(name, data){
// return that.newNode(name,data)
Expand Down
2 changes: 1 addition & 1 deletion src/physics/worker.js
Expand Up @@ -70,7 +70,7 @@ var PhysicsWorker = function(){
if (_physicsInterval===null) return
clearInterval(_physicsInterval);
_physicsInterval = null;
// postMessage('stopping')
postMessage({type:'stopping'})
},
tick:function(){
// iterate the system
Expand Down

0 comments on commit b2b57a8

Please sign in to comment.