Project

General

Profile

« Previous | Next » 

Revision 0c67ea13

Added by Leszek Koltunski about 2 years ago

Stars animation: support spending stars.

View differences:

src/main/java/org/distorted/overlays/OverlayStars.java
66 66
   private int mTotalStars, mNewStars;
67 67
   private FragmentEffectAlpha mAlpha;
68 68
   private Dynamic1D mAlphaStrength;
69
   private boolean mIncrease;
69 70

  
70 71
///////////////////////////////////////////////////////////////////////////////////////////////////
71 72

  
72
   private Dynamic3D createRandomMove()
73
   private Dynamic3D createRandomMove(boolean increase)
73 74
      {
74 75
      Dynamic3D move = new Dynamic3D();
75 76
      move.setMode(Dynamic.MODE_PATH);
......
86 87
      Static3D pointE = new Static3D(0,0,0);
87 88
      Static3D pointF = new Static3D(0,0,-10000);
88 89

  
89
      move.add(pointS);
90
      move.add(pointM);
91
      move.add(pointE);
92
      move.add(pointF);
90
      if( increase )
91
         {
92
         move.add(pointS);
93
         move.add(pointM);
94
         move.add(pointE);
95
         move.add(pointF);
96
         }
97
      else
98
         {
99
         move.add(pointF);
100
         move.add(pointE);
101
         move.add(pointM);
102
         move.add(pointS);
103
         }
93 104

  
94 105
      return move;
95 106
      }
......
137 148

  
138 149
///////////////////////////////////////////////////////////////////////////////////////////////////
139 150

  
140
   private DistortedNode createNode(Resources res, int numStars)
151
   private DistortedNode createNode(Resources res, int numStars, boolean increase)
141 152
      {
142 153
      // texture /////////////////////////////////////////////////////
143 154
      if( mTexture==null )
......
202 213

  
203 214
      for(int i=0; i<mNewStars; i++)
204 215
        {
205
        Dynamic3D moveP = createRandomMove();
216
        Dynamic3D moveP = createRandomMove(increase);
206 217
        VertexEffectMove moveE= new VertexEffectMove(moveP);
207 218
        moveE.setMeshAssociation(0,i);
208 219
        effects.apply(moveE);
......
252 263
      mWidth = mScreen.getWidth();
253 264
      mHeight= mScreen.getHeight();
254 265

  
255
      mNode = createNode(res,mTotalStars);
266
      mIncrease = mNewStars>0;
267
      if( !mIncrease ) mNewStars = -mNewStars;
268

  
269
      mNode = createNode(res,mTotalStars,mIncrease);
256 270
      mNode.glDepthMask(false);
257 271
      mNode.glStencilMask(0);
258 272
      mNode.enableDepthStencil(InternalOutputSurface.NO_DEPTH_NO_STENCIL);
......
285 299
         glow.notifyWhenFinished(this);
286 300
         DistortedEffects effects = mNode.getEffects();
287 301
         effects.apply(glow);
288

  
289
         renderStars(mTotalStars+mNewStars);
302
         renderStars(mTotalStars+(mIncrease ? mNewStars : -mNewStars));
290 303
         }
291 304
      if( id==mGlowID )
292 305
         {

Also available in: Unified diff