Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Native Development

BlackBerry Employee
Posts: 1
Registered: ‎01-22-2013
My Device: R072 London 1Gb RAM
My Carrier: Rogers

Jerky motions when using cocos2d-x

Hi Guys,


I am using the latest cocos2d-x (version: 2.0-x-2.0.4 from Nov 02, 2012) and I ended up having jerky motions primarily noticeable during rotations.


I am not sure for 100%, but it looks like it is a result of big differences between time gaps separating frames. Even if you run perfectly empty cocos2d-x scene and activate frame rate display - you will see that fame rate jumps like crazy from 46 to 58 (it supposed to be 60).


This frame rate controlled by code found in “cocos2dx/platform/blackberry/CCApplication.cpp” file, which is one of the files that binds cocos2d-x and BB10 platform. And this code relies on accuracy of clock_gettime(CLOCK_REALTIME,…)  function. This function must be very accurate (up to half of a millisecond) in order to guarantee more or less smooth motion; but it doesn’t look that it's the case. It is also better to have any timer synchronized with screen refresh - so that all OpenGL drawing for particular frame made by cocos2d-x will fall between two screen refreshes, and that would guarantee very smooth drawing (iOS has such timer and as result cosos2d renders motions very smooth).


So, can anyone answer how accurate is this clock_gettime(CLOCK_REALTIME,…)  function? And if it isn’t very accurate what should be used instead?


Second question: does BB10 platform have any screen refresh connected timer?


Guys, hundreds of apps and games are written using cocos2d for iOS and until cocos2d-x runs really smooth on BB10 platform it will be very challenging to port them.