Jump to content

300ms delay on Android devices


Phempt
 Share

Recommended Posts

Hello guys, I've a problem with "touchstart" event on android devices.

 

The touch event is detected 300ms later, and this cause a lot of problems.

 

I tried to solve using a meta tag:

<meta name="viewport" content="width=device-width, user-scalable=no">

but nothing, so I tried to download and configure a library ( https://github.com/ftlabs/fastclick ):

<script type="text/javascript" src="src/other/jquery-2.1.1.min.js"></script><script type="text/javascript" src="src/other/fastclick.js"></script><script type="text/javascript">    $(document).ready(function(){                $(function() {          FastClick.attach(document.body);        });        });</script>

but nothing, anyone can help me to solve this issue?

Link to comment
Share on other sites

yeah, this is my function (I used this on iOS with perfect result):

this.sprite.touchstart = this.sprite.click = function() {                                                                      if (game.system.paused != true) {                                                                      this.remove();                                                                      if (killHundred < 100) {                                                                      killHundred = killHundred + 1;                                                                      game.storage.set("killHundred", killHundred)                                                                      }                                                                      expNum = Math.floor(Math.random() * 2) + 1;                                                                      if (audioState == 0) {                                                                      if (expNum == 1) {                                                                      game.audio.playSound("laugh")                                                                      } else {                                                                      if (expNum == 2) {                                                                      game.audio.playSound("laugh1")                                                                      }                                                                      }                                                                      }                                                                      score = score - 10;                                                                      if (score < 0) {                                                                      score = 0                                                                      }                                                                      scoreText.setText(score.toString());                                                                      scoreText.updateTransform();                                                                      scoreText.position.x = 20;                                                                      scoreText.position.y = 20;                                                                      this.spriteAnimation = new game.Animation("objects/bubbles/obj-exp-evil_01.png", "objects/bubbles/obj-exp-evil_02.png", "objects/bubbles/obj-exp-evil_03.png", "objects/bubbles/obj-exp-evil_04.png", "objects/bubbles/obj-exp-evil_05.png", "objects/bubbles/obj-exp-evil_06.png");                                                                      this.spriteAnimation.position.set(this.position.x, this.position.y);                                                                      this.spriteAnimation.anchor.set(0.5, 0.5);                                                                      this.spriteAnimation.scale.set(0.8, 0.8);                                                                      this.spriteAnimation.animationSpeed = 0.1;                                                                      this.spriteAnimation.loop = false;                                                                      this.spriteAnimation.play();                                                                      game.scene.stage.addChild(this.spriteAnimation);                                                                      }                                                                      }

And this is the screenshot (61fps, really nice): http://oi61.tinypic.com/2i7plrc.jpg

Link to comment
Share on other sites

Update:

At the moment I tried with no results adding a preventDefault() function here:

a.touchstart = a.click = function(event){[...my code...]event.preventDefault();}

Than I tried with:

<script type="text/javascript">      window.addEventListener( "load", function() {        FastClick.attach( document.body );      }, false );</script>

instead of jQuery way without any results...

 

@enpu if you need the APK I can send it to you. Let me know ^_^

Link to comment
Share on other sites

I made other tests on other devices.

 

Working Devices:

- MotoG 2nd Generation 2014, Android 4.4.4

- Galaxy Note 10.1

- HTC Sensation, Android 4.0.3 (Thank you Oddskill)

 

Not Working Devices (Latency on Touchevents):

- Galaxy Note 8", Android 4.4.2

- Acer liquid Z3 Duo, Android 4.2

- Samsung Galaxy S3 (gt-I9300) Android 4.3.2

 

If you want to try the alpha version, download this APK. It's not optimized, because I'm trying to solve the latency issue before convert the sound and change the sprite.

 

(Please if you write a feedback, add your device specifications)

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

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