【问题标题】:I need to make a particle animation but the particles always start from pixel 0,0我需要制作粒子动画,但粒子总是从像素 0,0 开始
【发布时间】:2015-08-24 15:30:42
【问题描述】:

这是我需要制作的动画: https://www.dropbox.com/s/xvyj550i43gg6wz/2015-08-24%2013.12.57.mp4?dl=0 我开始研究它,使用 Leonids 库: https://github.com/plattysoft/Leonids 现在我创建了一个particleSystem 创建器,并将它设置在我的发射器上,但应用程序将始终从屏幕的0,0(左上角)点开始飞溅粒子。 我怎样才能让它从我的视野中发出? 这就是我启动它的方式:

  new ParticleSystem(PSHiscoreAnimationActivity.this, 1000, R.drawable.icn_planning_dot, 10000)
            .setAcceleration(0.00013f, 90)
            .setSpeedByComponentsRange(0f, 0f, 0.05f, 0.1f)
            .setFadeOut(200, new AccelerateInterpolator())
            .emitWithGravity(emitter, Gravity.BOTTOM, 30);

这是我的布局:

<View android:id="@+id/emitter"
    android:layout_centerInParent="true"
    android:background="@color/blue"
    android:layout_width="10dp"
    android:layout_height="10dp" />

【问题讨论】:

  • 不要包含您在得到答案后有意删除的链接

标签: android animation ondraw particles particle-system


【解决方案1】:

看来问题可能出在您的启动位置。 请参阅Issue #22 of the github project 其他人有来自左上角的粒子问题。如果您在 onStart 或 onCreate 中调用它,它将无法正常工作,因为尚未测量视图,他们建议使用 ViewTreeObserver,如 this Stackoverflow answer

【讨论】:

  • 谢谢,它在我的 onCreate 中,将尝试移动代码,看看接下来会发生什么。一旦我设法让它工作,我会通知你
  • 再次感谢,如果我使用 ViewTreeObserver 就可以了
猜你喜欢
  • 2017-08-11
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多