use this function, may help, if you download my game budgie you can find this in the library game, in the first line.