动画IST只有当顺利时ontouchevent称为 [英] Animation ist only smooth when ontouchevent is called

查看:163
本文介绍了动画IST只有当顺利时ontouchevent称为的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在做使用surfaceview,并在画布上绘制的东西(很多原语放在不同的路径对象的)我的第一个2D的sidescroller游戏。
我的游戏循环使用直线插补固定的时间步长。我在游戏过程中不会产生任何对象。我一直在提高我的code 3个星期了,但我的动画仍然不是所有的时间顺利。这是确定的,但每隔几秒钟有大约1或2秒许多小希克斯。
我承认是,当我提出我的球员(这意味着触摸屏),小希克斯消失只要我触摸屏幕和移动我的球员。
这意味着只要surfaceview的ontouchevent被调用时,动画是平滑的。
我不明白这一点,我希望有一个平滑的动画。有人可以帮我吗?

i'm making my first 2d sidescroller game using a surfaceview and a canvas to draw things on (a lot of primitives put in different path objects). my game loop uses fixed timesteps with linear interpolation. i don't create any objects during the game. i've been improving my code for 3 weeks now, but my animation is still not all the time smooth. it's ok, but every few seconds there are a lot of little hicks for about 1 or 2 seconds. what i recognized is when i move my player (this means touching the screen), the little hicks disappear for as long as i touch the screen and move my player. this means as long as ontouchevent of the surfaceview is called, the animation is smooth. i dont understand this and i want a smooth animation. can somebody help me?

推荐答案

这听起来像在某些设备上的已知问题。见例如:

This sounds like a known issue on certain devices. See e.g.:

  • Android SurfaceView slows if no touch events occur
  • Animation glitches while rendering on SurfaceView
  • Android thread performance/priority on Galaxy Note 2 when screen is touched/released

的问题是,该系统积极地减少时钟速度以节省功率时它不检测与用户的交互。 (高通在特定看来喜欢这一点。)解决办法是在必要时丢弃帧。请参见在游戏圈这篇文章,并展示了基于编舞招 Grafika的记录GL应用的活动(在<一个href=\"https://github.com/google/grafika/blob/master/src/com/android/grafika/RecordFBOActivity.java#L836\"相对=nofollow> doFrame() )。

The problem is that the system is aggressively reducing clock speeds to save power when it doesn't detect interaction with the user. (Qualcomm in particular seems fond of this.) The workaround is to drop frames when necessary. See this article on game loops, and a Choreographer-based trick demonstrated in Grafika's "record GL app" activity (in doFrame()).

这篇关于动画IST只有当顺利时ontouchevent称为的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆