AndEngine 엔진의 학습 노트(3)
2967 단어 엔진
final LoopEntityModifier entityModifier = new LoopEntityModifier(// Modifier
new IEntityModifierListener() {// ModifierListener , Modifier
@Override
public void onModifierStarted(
final IModifier<IEntity> pModifier,
final IEntity pItem) {
EntityModifierExample.this.runOnUiThread(new Runnable() {
@Override
public void run() {
Toast.makeText(EntityModifierExample.this,
"Sequence started.", Toast.LENGTH_SHORT)
.show();
}
});
}
@Override
public void onModifierFinished(
final IModifier<IEntity> pEntityModifier,
final IEntity pEntity) {
EntityModifierExample.this.runOnUiThread(new Runnable() {
@Override
public void run() {
Toast.makeText(EntityModifierExample.this,
"Sequence finished.",
Toast.LENGTH_SHORT).show();
}
});
}
}, 2, new ILoopEntityModifierListener() {// ModifierListener , Modifier 。
@Override
public void onLoopStarted(
final LoopModifier<IEntity> pLoopModifier,
final int pLoop, final int pLoopCount) {
EntityModifierExample.this
.runOnUiThread(new Runnable() {
@Override
public void run() {
Toast.makeText(
EntityModifierExample.this,
"Loop: '" + (pLoop + 1)
+ "' of '" + pLoopCount
+ "' started.",
Toast.LENGTH_SHORT).show();
}
});
}
@Override
public void onLoopFinished(
final LoopModifier<IEntity> pLoopModifier,
final int pLoop, final int pLoopCount) {
EntityModifierExample.this
.runOnUiThread(new Runnable() {
@Override
public void run() {
Toast.makeText(
EntityModifierExample.this,
"Loop: '" + (pLoop + 1)
+ "' of '" + pLoopCount
+ "' finished.",
Toast.LENGTH_SHORT).show();
}
});
}// , 。
}, new SequenceEntityModifier(new RotationModifier(1, 0, 90),// , ParallelEntityModifier
new AlphaModifier(2, 1, 0), new AlphaModifier(1, 0, 1),
new ScaleModifier(2, 1, 0.5f), new DelayModifier(0.5f),
new ParallelEntityModifier(
new ScaleModifier(3, 0.5f, 5),
new RotationByModifier(3, 90)),
new ParallelEntityModifier(new ScaleModifier(3, 5, 1),
new RotationModifier(3, 180, 0))));
face.registerEntityModifier(entityModifier);// face
rect.registerEntityModifier(entityModifier.deepCopy());// Modifier rect 。
EntityModifierExample
이번에 본 것은 EntityModifier Example입니다. Modifier의 용법은 말 그대로 Sprite 종류를 수식하는 데 사용되고 코드 주석을 구체적으로 보면 명확합니다.