Skip to content

Commit

Permalink
fix bug in folder names
Browse files Browse the repository at this point in the history
  • Loading branch information
lfkdsk committed Jan 1, 2017
1 parent bb5e7ac commit db7ae82
Show file tree
Hide file tree
Showing 99 changed files with 11,423 additions and 0 deletions.
29 changes: 29 additions & 0 deletions engine/src/main/java/com/lfk/justweengine/anim/AliveAnimation.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package com.lfk.justweengine.anim;

import com.lfk.justweengine.engine.GameTimer;

/**
* 判断生死
*
* @author liufengkai
* Created by liufengkai on 15/12/5.
*/
public class AliveAnimation extends BaseAnim {
private int liftTime;
private GameTimer timer;

public AliveAnimation(int liftTime) {
this.liftTime = liftTime;
this.timer = new GameTimer();
animating = true;
animType = AnimType.ALIVE;
}

@Override
public boolean adjustAlive(boolean ori) {
if (liftTime > 0 && timer.stopWatch(liftTime)) {
ori = false;
}
return ori;
}
}
41 changes: 41 additions & 0 deletions engine/src/main/java/com/lfk/justweengine/anim/AlphaAnimation.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
package com.lfk.justweengine.anim;

/**
* 透明度动画
*
* @author liufengkai
* Created by liufengkai on 15/11/28.
*/
public class AlphaAnimation extends BaseAnim {
private int maxAlpha;
private int minAlpha;
private int changeAlpha;

public AlphaAnimation(int changeAlpha) {
this(255, 0, changeAlpha);
}

public AlphaAnimation(int maxAlpha, int minAlpha, int changeAlpha) {
super();
this.maxAlpha = maxAlpha;
this.minAlpha = minAlpha;
this.changeAlpha = changeAlpha;
this.animType = AnimType.ALPHA;
this.animating = true;
}

@Override
public int adjustAlpha(int ori) {
int modified = ori;
modified += changeAlpha;
if (modified < minAlpha) {
modified = minAlpha;
animating = false;
}
if (modified > maxAlpha) {
modified = maxAlpha;
animating = false;
}
return modified;
}
}
36 changes: 36 additions & 0 deletions engine/src/main/java/com/lfk/justweengine/anim/AnimType.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
package com.lfk.justweengine.anim;

/**
* 动画类型
*
* @author liufengkai
* Created by liufengkai on 15/11/28.
*/
public enum AnimType {
// anim with frame change
FRAME,

ALPHA,

SCALE,

ROTATION,

POSITION,

WRAPMOVE,

ALIVE,

SHOOT,

ZOOM,

ZOOM_CENTER,

MASK,

COLOR,

NULL
}
55 changes: 55 additions & 0 deletions engine/src/main/java/com/lfk/justweengine/anim/BaseAnim.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
package com.lfk.justweengine.anim;

import android.graphics.Rect;
import android.renderscript.Float2;

/**
* 动画基类
*
* @author liufengkai
* Created by liufengkai on 15/11/28.
*/
public class BaseAnim {
// Is it running ?
public boolean animating;
// anim type
public AnimType animType;

// init
public BaseAnim() {
animating = false;
animType = AnimType.NULL;
}

public int adjustAlpha(int ori) {
return ori;
}

public int adjustFrame(int ori) {
return ori;
}

public Float2 adjustScale(Float2 ori) {
return ori;
}

public float adjustRotation(float ori) {
return ori;
}

public Float2 adjustPosition(Float2 ori) {
return ori;
}

public boolean adjustAlive(boolean ori) {
return ori;
}

public Rect adjustScale(Rect ori) {
return ori;
}

public float adjustTag(float ori) {
return ori;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
package com.lfk.justweengine.anim;

import android.graphics.Point;
import android.renderscript.Float2;

/**
* Created by liufengkai on 15/11/29.
*/
public class CircleMoveAnimation extends BaseAnim {
private int radius;
private Point center;
private double angle;
private float velocity;

public CircleMoveAnimation(int centerX, int centerY,
int radius, double angle,
float velocity) {
animating = true;
animType = AnimType.POSITION;
this.center = new Point(centerX, centerY);
this.radius = radius;
this.angle = angle;
this.velocity = velocity;
}

@Override
public Float2 adjustPosition(Float2 ori) {
angle += velocity;
ori.x = (int) (center.x + (float) (Math.cos(angle) * radius));
ori.y = (int) (center.y + (float) (Math.sin(angle) * radius));
return ori;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package com.lfk.justweengine.anim;

/**
* Created by liufengkai on 15/12/2.
*/
public interface DoAfterAnimation {
void afterAnimation();
}
33 changes: 33 additions & 0 deletions engine/src/main/java/com/lfk/justweengine/anim/FenceAnimation.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
package com.lfk.justweengine.anim;

import android.graphics.Rect;
import android.renderscript.Float2;

/**
* 围栏使用动画防止出界
*
* @author liufengkai
* Created by liufengkai on 15/12/4.
*/
public class FenceAnimation extends BaseAnim {
private Rect fence;

public FenceAnimation(Rect fence) {
this.fence = fence;
animating = true;
animType = AnimType.POSITION;
}

@Override
public Float2 adjustPosition(Float2 ori) {
if (ori.x < fence.left)
ori.x = fence.left;
else if (ori.x > fence.right)
ori.x = fence.right;
else if (ori.y < fence.top)
ori.y = fence.top;
else if (ori.y > fence.bottom)
ori.y = fence.bottom;
return ori;
}
}
52 changes: 52 additions & 0 deletions engine/src/main/java/com/lfk/justweengine/anim/FrameAnimation.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
package com.lfk.justweengine.anim;

import com.lfk.justweengine.engine.GameTimer;

/**
* 逐帧动画
*
* @author liufengkai
* Created by liufengkai on 15/11/29.
*/
public class FrameAnimation extends BaseAnim {
private int firstFrame;
private int lastFrame;
private int direction;
private int interval;
// 帧动画切换时间间隔,单位ms
private GameTimer timer;

public FrameAnimation(int firstFrame, int lastFrame, int direction) {
this.firstFrame = firstFrame;
this.lastFrame = lastFrame;
this.direction = direction;
this.animType = AnimType.FRAME;
this.animating = true;
this.interval = 0;
timer = new GameTimer();
}

public FrameAnimation(int firstFrame, int lastFrame, int direction, int interval) {
this.firstFrame = firstFrame;
this.lastFrame = lastFrame;
this.direction = direction;
this.animType = AnimType.FRAME;
this.animating = true;
this.interval = interval;
timer = new GameTimer();
}

@Override
public int adjustFrame(int ori) {
int modified = ori;
if (timer.stopWatch(interval)) {
modified += direction;
if (modified < firstFrame) {
modified = lastFrame;
} else if (modified > lastFrame) {
modified = firstFrame;
}
}
return modified;
}
}
45 changes: 45 additions & 0 deletions engine/src/main/java/com/lfk/justweengine/anim/MoveAnimation.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
package com.lfk.justweengine.anim;

import android.renderscript.Float2;
import android.util.Log;

/**
* Created by liufengkai on 15/12/3.
*/
public class MoveAnimation extends BaseAnim {
private Float2 velocity;
private float toX;
private float toY;

public MoveAnimation(
float toX, float toY,
Float2 velocity) {
this.toX = toX;
this.toY = toY;
this.velocity = velocity;
animating = true;
animType = AnimType.POSITION;
}

@Override
public Float2 adjustPosition(Float2 ori) {
if (ori.x != toX) {
if (ori.x > toX)
ori.x -= velocity.x;
else
ori.x += velocity.x;
}
if (ori.y != toY) {
Log.d("ori.y" + ori.y, "toY" + toY);
if (ori.y > toY)
ori.y -= velocity.y;
else
ori.y += velocity.y;
}
if (Math.abs(ori.x - toX) < velocity.x &&
Math.abs(ori.y - toY) < velocity.y) {
animating = false;
}
return ori;
}
}
34 changes: 34 additions & 0 deletions engine/src/main/java/com/lfk/justweengine/anim/ShootAnimation.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
package com.lfk.justweengine.anim;

import android.renderscript.Float2;

import com.lfk.justweengine.info.UIdefaultData;

/**
* Created by liufengkai on 15/12/5.
*/
public class ShootAnimation extends BaseAnim {
private float speed;
private float y;

public ShootAnimation(float y, float v) {
this.speed = v;
this.y = y;
animating = true;
animType = AnimType.SHOOT;
}

@Override
public Float2 adjustPosition(Float2 original) {
y = original.y += speed;
return original;
}

@Override
public boolean adjustAlive(boolean ori) {
if (y < 0 || y > UIdefaultData.screenHeight) {
ori = false;
}
return ori;
}
}
Loading

3 comments on commit db7ae82

@ice1000
Copy link

@ice1000 ice1000 commented on db7ae82 Jan 1, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

终于改邪归正了(话说git的大小写处理有点猥琐啊)

@lfkdsk
Copy link
Owner Author

@lfkdsk lfkdsk commented on db7ae82 Jan 2, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

简直太奇怪了

@lfkdsk
Copy link
Owner Author

@lfkdsk lfkdsk commented on db7ae82 Jan 2, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

我把大小写敏感开了之后,居然同时存在里~两份

Please sign in to comment.