Project

General

Profile

Download (2.51 KB) Statistics
| Branch: | Revision:

distorted-objectlib / src / main / java / org / distorted / objectlib / effects / objectchange / ObjectChangeEffectMove.java @ 1eafa9c6

1
///////////////////////////////////////////////////////////////////////////////////////////////////
2
// Copyright 2019 Leszek Koltunski                                                               //
3
//                                                                                               //
4
// This file is part of Magic Cube.                                                              //
5
//                                                                                               //
6
// Magic Cube is proprietary software licensed under an EULA which you should have received      //
7
// along with the code. If not, check https://distorted.org/magic/License-Magic-Cube.html        //
8
///////////////////////////////////////////////////////////////////////////////////////////////////
9

    
10
package org.distorted.objectlib.effects.objectchange;
11

    
12
import org.distorted.library.effect.Effect;
13
import org.distorted.library.effect.MatrixEffectMove;
14
import org.distorted.library.type.Dynamic3D;
15
import org.distorted.library.type.Static3D;
16

    
17
///////////////////////////////////////////////////////////////////////////////////////////////////
18

    
19
class ObjectChangeEffectMove extends ObjectChangeEffect
20
  {
21
  public int createEffectsPhase0(int duration)
22
    {
23
    int w = mObjectNode.getWidth();
24
    int h = mObjectNode.getHeight();
25
    int xmove = w/2 + (w<h?w:h)/2;
26

    
27
    mNodeEffectPosition[0] = new int[] {1};
28
    mNodeEffects[0]        = new Effect[mNodeEffectPosition[0].length];
29

    
30
    Dynamic3D d0 = new Dynamic3D(duration/2, 0.5f);
31
    d0.add(new Static3D(    0,0,0));
32
    d0.add(new Static3D(xmove,0,0));
33
    mNodeEffects[0][0] = new MatrixEffectMove(d0);
34

    
35
    return 1;
36
    }
37

    
38
///////////////////////////////////////////////////////////////////////////////////////////////////
39

    
40
  public int createEffectsPhase1(int duration)
41
    {
42
    int w = mObjectNode.getWidth();
43
    int h = mObjectNode.getHeight();
44
    int xmove = w/2 + (w<h?w:h)/2;
45

    
46
    mNodeEffectPosition[1] = new int[] {1};
47
    mNodeEffects[1]        = new Effect[mNodeEffectPosition[1].length];
48

    
49
    Dynamic3D d0 = new Dynamic3D(duration/2, 0.5f);
50
    d0.add(new Static3D(-xmove,0,0));
51
    d0.add(new Static3D(     0,0,0));
52
    mNodeEffects[1][0] = new MatrixEffectMove(d0);
53

    
54
    return 1;
55
    }
56

    
57
///////////////////////////////////////////////////////////////////////////////////////////////////
58
// Enable all effects used in this Effect. Called by reflection from the parent class.
59
// Matrix Effects do not have to be enabled.
60

    
61
  @SuppressWarnings("unused")
62
  static void enable()
63
    {
64

    
65
    }
66
  }
67

    
(2-2/6)