Jump to content

game.input event reduces framerate on mobile


Recommended Posts

I am pretty new to Phaser and enjoy it very much, and also use cocoonjs to test on a mobile device.

If I have any game.input event - like "game.input.onDown.add (function)" etc, in the update function, after a minute or so of no activity (on the mobile) my framerate goes through the floor. I am wondering why this might be.  I can add a timer to test for activity and pause the game, but I am curious if I am doing something wrong.

Below, is my html file - if I zip the html and phaser.min file, and open it on my iPhone and don't do anything it starts at 60fps.  Then after about a minute or so of inactivity, the framerate drops to 20+

Tested on various Phaser versions, including 2.4.4

<doctype html>
<script src="phaser.min.js"></script>
<script type="text/javascript">

var game = new Phaser.Game(320, 480, Phaser.AUTO, '', { preload: preload, create: create, update: update });

function preload() {

function create() {

function update () {


Link to comment
Share on other sites

You shouldn't add that event listener in the update function.  Each time it loops it's going to be adding yet another listener, and this will eat up memory very fast.  Move that code into your create function.  Should help a lot, as the listener only needs to get added once to work.

Link to comment
Share on other sites


  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Create New...