2015-08-24 37 views
-1

這是我需要做動畫: https://www.dropbox.com/s/xvyj550i43gg6wz/2015-08-24%2013.12.57.mp4?dl=0 我開始做這個工作,用獅子座流星雨庫: https://github.com/plattysoft/Leonids 現在我做一個粒子系統的創造者,我將其設置在我的發射器上,但應用程序將始終從屏幕的0,0(左上角)點開始飛濺粒子。 我如何讓它從我的視野中散發出來? 這是我如何啓動它:我需要做一個粒子動畫,但顆粒總是從像素開始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" /> 

+0

不要包含你一旦得到你的意圖就刪除的鏈接回答 – gregoiregentil

回答

1

看來問題可能是你在哪裏啓動它。 請參閱Issue #22 of the github project其中有人有問題的粒子來自左上角。如果你是從onStart或onCreate調用它,它將無法正常工作,因爲視圖還沒有被測量,並且他們建議使用ViewTreeObserver,如this Stackoverflow answer

+0

謝謝,它在我的onCreate中,會嘗試移動代碼並看看接下來會發生什麼。一旦我設法使它工作,我會讓你知道 –

+1

再次感謝,如果我使用ViewTreeObserver –