I began writing some accelerometer support by hijacking the existing touch/es infrastructure. My first stab (before re-factoring out the common script hook handling code to a seperate (touch-agnostic) location) can be found here : https://github.com/ciaranj/cocos2d-x/tree/add\_accelerometer\_bindings\_to\_lua
This works, ‘woot!’ … however it suggests a somewhat fundamental issue. There appears to be no locking within LuaEngineImpl Which means that I have both:
cocos2d.CCScheduler:sharedScheduler():scheduleScriptFunc(“tick”, 0.01, false)
firing, sometimes (and oddly only for android?) they (I think) occur con-currently so lua’s global state ends up in an in-consistent manner (and seg-faults)
I’m not too clear on the threading models involved, can anyone explain them? .. I’m surprised that I don’t see the issue on iOS tbh, so I can only assume that the thread-locking/spawning is being dealt with outside of the code, but not for the android, I also don’t understand why this doesn’t affect the touch/es handlers ?