I have a touch problem. I have some word sprites, and I bind the touch event (below) to them. After I touch one of them a few times consecutively and them want to drag, firstly the touch event does not respond, but if I wait a second then I can drag. In the LogCat I get this:
12-28 17:23:58.979: V/AndEngine(23295): org.andengine.util.adt.pool.PoolUpdateHandler$1 was exhausted, with 1 item not yet recycled. Allocated 1 more.
How do I fix this problem?
Here is the touch event code:
public boolean onAreaTouched(TouchEvent pSceneTouchEvent, float pTouchAreaLocalX, float pTouchAreaLocalY)
{
switch(pSceneTouchEvent.getAction()) {
case TouchEvent.ACTION_DOWN:
this.mGrabbed = true;
break;
case TouchEvent.ACTION_MOVE:
if(this.mGrabbed)
this.setPosition(pSceneTouchEvent.getX() - 18, pSceneTouchEvent.getY() - 15);
break;
case TouchEvent.ACTION_UP:
if(this.mGrabbed)
{
this.mGrabbed = false;
boolean found = false;
float x1,x2,y1,y2;
if(this.getY() < 350)
{
for(int i = 0; i < positions_list.size(); i++)
{
if((word_object_list.get(a).getName().equals(positions_list.get(i).getName())) && positions_list.get(i).isFree())
{
x1 = word_object_list.get(a).getSprite().getX();
y1 = word_object_list.get(a).getSprite().getY();
x2 = positions_list.get(i).getxPosition();
y2 = positions_list.get(i).getyPosition();
x1 = Math.abs(x2-x1);
y1 = Math.abs(y2-y1);
x1 = (float) Math.pow(x1,2);
y1 = (float) Math.pow(y1, 2);
x1 = x1+y1;
x1 = (float) Math.sqrt(x1);
if(x1 < 20)
{
// Set hint's visibility false
if(i == 0 && sprite_word_hint_1 != null)
sprite_word_hint_1.setVisible(false);
if(i == random_hint_position && sprite_word_hint_2 != null)
sprite_word_hint_2.setVisible(false);
word_object_list.get(a).getSprite().setVisible(false);
sprite_word_true_list.get(i).setVisible(true);
sprite_candy_list.get(finish_state).setVisible(true);
finish_state ++;
if(finish_state == question.getWord().length())
{
// Create new scene
Game_Screen.this.getEngine().registerUpdateHandler(new TimerHandler(6.5f, new ITimerCallback() {
public void onTimePassed(TimerHandler pTimerHandler) {
// TODO Auto-generated method stub
Game_Screen.this.getEngine().setScene(load_new_scene());
remove_textures();
}
}));
// Increase point
Game_Screen.this.getEngine().registerUpdateHandler(new TimerHandler(4.3f, new ITimerCallback() {
public void onTimePassed(TimerHandler pTimerHandler) {
// TODO Auto-generated method stub
int point = variables.getDatabase().get_point(variables.getCategory_level())+question.getWord().length();
elapsedText.setText(""+point);
variables.getDatabase().set_answered(question);
variables.getDatabase().update_user(question, question.getWord().length(), hint_used);
}
}));
// Cover animation
sprite_cover.setRotationCenter(sprite_cover.getRotationCenterX()+20, sprite_cover.getRotationCenterY());
sprite_cover.registerEntityModifier(new SequenceEntityModifier(
new DelayModifier(1),
new RotationModifier(1.5f, 0, 90),
new DelayModifier(1.7f),
new RotationModifier(1, 90, -0)
)
);
// Candy animation
for(int j = 0; j < sprite_candy_list.size(); j++)
{
sprite_candy_list.get(j).registerEntityModifier(new SequenceEntityModifier(
new DelayModifier(2.7f),
new CubicBezierCurveMoveModifier( 1.5f, sprite_candy_list.get(j).getX(), sprite_candy_list.get(j).getY(), 165, 240, 166, 241, 275, 400, EaseQuadIn.getInstance()),
new DelayModifier(0.2f),
new AlphaModifier(1, 1, 0)
)
);
}
}
positions_list.get(i).setFree(false);
found = true;
break;
}
}
}
}
if(!found)
{
word_object_list.get(a).getSprite().registerEntityModifier(new MoveModifier(1, word_object_list.get(a).getSprite().getX(), word_object_list.get(a).getPositionX(), word_object_list.get(a).getSprite().getY(), word_object_list.get(a).getPositionY(),EaseQuadIn.getInstance()));
}
}
break;
}
return true;
}