\Hello.
I need help in my game i designed infinit game .it about killing bad people and dont kill good one my game consist of 12 characters 6 good,6 bad when i kill good women scream should appear and red blood replace of it and after 2 sec the blood removed ,so my question is when i kill good one or bad one another one must appear instead of the killed one .
i will put the code for touch events and code for add character
thanks
Notes: sprite,temp is an array list from this class.iused them to insert imgs to theme
@Override
public boolean onTouchEvent(MotionEvent event) {
if (System.currentTimeMillis() - lastClick > 300) {
lastClick = System.currentTimeMillis();
float x = event.getX();
float y = event.getY();
synchronized (getHolder()) {
for (int i = charc.size() - 1; i >= 0; i--) {
Characters sprite = charc.get(i);
if (sprite.isCollition(x, y)) {
charc.remove(sprite);
temp.add(new TempToRemove(temp, this, x, y, bmpBlood1));
break;
}
}
for (int i = chara.size() - 1; i >= 0; i--) {
Characters sprite = chara.get(i);
if (sprite.isCollition(x, y)) { chara.remove(sprite)
temp.add(new TempToRemove(temp, this, x, y, bmpBlood));
break;
}
}
}
}
return true;
}
and this code for add sprites:
private void createSprites() {
charc.add(createSprite(R.drawable.bad1));
charc.add(createSprite(R.drawable.bad2));
charc.add(createSprite(R.drawable.bad3));
charc.add(createSprite(R.drawable.bad4));
charc.add(createSprite(R.drawable.bad5));
charc.add(createSprite(R.drawable.bad6));
chara.add(createSprite(R.drawable.good1));
chara.add(createSprite(R.drawable.good2));
chara.add(createSprite(R.drawable.good3));
chara.add(createSprite(R.drawable.good4));
chara.add(createSprite(R.drawable.good5));
chara.add(createSprite(R.drawable.good6));
}
private Characters createSprite(int resouce) {
Bitmap bmp = BitmapFactory.decodeResource(getResources(), resouce);
return new Characters(this, bmp);
}
and this function paint on Canvas:
protected void onDraw(Canvas canvas) {
canvas.drawColor(Color.BLACK);
for (int i = temp.size() - 1; i >= 0; i--) {
temp.get(i).onDraw(canvas);
}
for (Characters sprite : charc) {
sprite.onDraw(canvas);
}