我想要实现的是更改 mRectangles 属性,例如用户在设置中更改它的持续时间。我已经读过我想将 modifier.reset() 与原始的相应参数一起使用。我似乎无法弄清楚我应该在第四个参数中传递什么。我应该调用一个变量或函数来获得正确的上下文吗?
@Override
public void onPopulateScene(Scene pScene,
OnPopulateSceneCallback pOnPopulateSceneCallback) throws Exception {
// TODO Auto-generated method stub
Rectangle mRectangle = new Rectangle(0, 0, CAMERA_WIDTH, CAMERA_HEIGHT,
mEngine.getVertexBufferObjectManager());
// With this anonymous function, you can add events to the beginning and end
// of the modified state
IEntityModifierListener mIEntityModifierListener = new IEntityModifierListener() {
@Override
public void onModifierStarted(IModifier<IEntity> pModifier,
IEntity pItem) {
// Grab the current duration value and compare it to the
// one that's stored
final int mDuration = (int) pModifier.getDuration();
Log.i("MODIFIER", "Current duration value: " + mDuration);
if(mDuration != mDurationPref)
{
Log.i("UPDATEDURATION","Duration value: " + mDurationPref);
mFinalDuration = mDurationPref;
pModifier.reset();
}
else
{
Log.i("UPDATEDURATION","Both values match: " + COLORONE_DEFAULT);
mFinalDuration = COLORONE_DEFAULT;
}
}
@Override
public void onModifierFinished(IModifier<IEntity> pModifier,
IEntity pItem) {
// TODO Auto-generated method stub
Log.i("MODIFIER", "It finished!");
}
};
Log.i("FINALDURATIONVALUE", "Final duration: " + mFinalDuration);
// This is where you can chain up the colors
// TODO: Make this in to a function that interpolates the colors together
ColorModifier mColorModifier = new ColorModifier(5, Color.CYAN,
Color.RED, mIEntityModifierListener, EaseSineIn.getInstance());
ColorModifier tColorModifier = new ColorModifier(5, Color.RED,
Color.CYAN, EaseSineInOut.getInstance());
ColorModifier iColorModifier = new ColorModifier(5, Color.CYAN,
Color.GREEN, mIEntityModifierListener, EaseSineIn.getInstance());
ColorModifier xColorModifier = new ColorModifier(5, Color.GREEN,
Color.YELLOW, EaseSineInOut.getInstance());
ColorModifier yColorModifier = new ColorModifier(5, Color.YELLOW,
Color.CYAN, mIEntityModifierListener, EaseSineIn.getInstance());
// The sequence modifier will go through the color modifiers
// and the loop entity modifier makes it continuous
SequenceEntityModifier mSequenceEntityModifier = new SequenceEntityModifier(
mColorModifier, tColorModifier, iColorModifier, xColorModifier,
yColorModifier);
LoopEntityModifier mLoopEntityModifier = new LoopEntityModifier(
mSequenceEntityModifier);
mRectangle.registerEntityModifier(mLoopEntityModifier);
scene.attachChild(mRectangle);
pOnPopulateSceneCallback.onPopulateSceneFinished();
}