Skip to content

Commit

Permalink
Update TouchEventListener CoordinateType and fix minor error
Browse files Browse the repository at this point in the history
  • Loading branch information
iamoscarliang committed Nov 20, 2023
1 parent 9210e11 commit cb19cb4
Show file tree
Hide file tree
Showing 7 changed files with 38 additions and 9 deletions.
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
package com.nativegame.nattyengine.util.modifier;
package com.nativegame.nattyengine.entity.modifier;

import com.nativegame.nattyengine.entity.Entity;
import com.nativegame.nattyengine.util.modifier.BaseModifier;

/**
* Created by Oscar Liang on 2022/12/11
*/

public class DurationModifier extends BaseModifier<Entity> {

private boolean mIsAutoRemove = false;

//--------------------------------------------------------
// Constructors
//--------------------------------------------------------
Expand All @@ -20,6 +23,18 @@ public DurationModifier(long duration, long startDelay) {
}
//========================================================

//--------------------------------------------------------
// Getter and Setter
//--------------------------------------------------------
public boolean isAutoRemove() {
return mIsAutoRemove;
}

public void setAutoRemove(boolean autoRemove) {
mIsAutoRemove = autoRemove;
}
//========================================================

//--------------------------------------------------------
// Overriding methods
//--------------------------------------------------------
Expand All @@ -33,6 +48,9 @@ protected void onUpdateModifier(Entity entity, float durationPercentage) {

@Override
protected void onEndModifier(Entity entity) {
if (mIsAutoRemove) {
entity.removeFromGame();
}
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
import com.nativegame.nattyengine.entity.particle.modifier.RotationParticleModifier;
import com.nativegame.nattyengine.entity.particle.modifier.ScaleParticleModifier;
import com.nativegame.nattyengine.util.math.RandomUtils;
import com.nativegame.nattyengine.util.modifier.DurationModifier;
import com.nativegame.nattyengine.entity.modifier.DurationModifier;
import com.nativegame.nattyengine.util.modifier.Modifier;
import com.nativegame.nattyengine.util.pool.Pool;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,10 @@ public boolean isLooping() {
public void setLooping(boolean looping) {
mIsLooping = looping;
}

public List<TimerEvent> getAllTimerEvents() {
return mEvents;
}
//========================================================

//--------------------------------------------------------
Expand Down Expand Up @@ -107,7 +111,6 @@ public void stopTimer() {
mEventCount = 0;
mTotalEventTime = 0;
mTotalTime = 0;
System.out.println("end");
}

public void pauseTimer() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@ public class TimerEvent {
//--------------------------------------------------------
// Constructors
//--------------------------------------------------------
public TimerEvent(TimerEventListener listener) {
this(listener, 0);
}

public TimerEvent(TimerEventListener listener, long time) {
mListener = listener;
mEventTime = time;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@

public interface BoundTouchEventListener {

Camera.CoordinateType getCoordinateType();

void setCoordinateType(Camera.CoordinateType type);
default Camera.CoordinateType getCoordinateType() {
return Camera.CoordinateType.WORLD;
}

float getX();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@

public interface TouchEventListener {

Camera.CoordinateType getCoordinateType();

void setCoordinateType(Camera.CoordinateType type);
default Camera.CoordinateType getCoordinateType() {
return Camera.CoordinateType.WORLD;
}

void onTouchEvent(int type, float touchX, float touchY);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,10 @@ public float getEndValueY() {
return mEndValueY;
}

public void setValue(float startValue, float endValue) {
setValue(startValue, endValue, startValue, endValue);
}

public void setValue(float startValueX, float endValueX, float startValueY, float endValueY) {
mStartValueX = startValueX;
mStartValueY = startValueY;
Expand Down

0 comments on commit cb19cb4

Please sign in to comment.