-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathEnemyLaserPool.java
58 lines (47 loc) · 1.77 KB
/
EnemyLaserPool.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
package mkat.apps.spacewars;
import org.andengine.entity.sprite.Sprite;
import org.andengine.util.adt.pool.GenericPool;
import android.util.Log;
public class EnemyLaserPool extends GenericPool<EnemyLaser> {
/* The pool constructor assigns the necessary objects needed to
* construct sprites */
public EnemyLaserPool(int i){
super(i);
}
/* onAllocatePoolItem handles the allocation of new sprites in the
event that we're attempting to obtain a new item while all pool
items are currently in use */
protected EnemyLaser onAllocatePoolItem(float x, float y, float angle, Enemy callingEnemy) {
//super.onAllocatePoolItem();
//Log.v("","runs to allocate a enemy laser");
EnemyLaser el = new EnemyLaser(GameLevel.getInstance().pEnemyLaserTexture, x, y, angle, callingEnemy);
//GameLevel.getInstance().attachChild(pl);
return el;
}
//GameLevel.getInstance().attachChild(pl);
//Log.v("something", "enemy created with modifiers and listeners");
@Override
protected void onHandleRecycleItem(EnemyLaser pItem){
super.onHandleRecycleItem(pItem);
pItem.clearEntityModifiers();
pItem.clearUpdateHandlers();
pItem.setVisible(false);
pItem.reset();
//GameLevel.getInstance().recycleBullet = true;
//Log.v("","recycled a enemy laser icon3");
}
public synchronized EnemyLaser obtainPoolItem(float x, float y, float angle, Enemy callingEnemy) {
// TODO Auto-generated method stub
super.obtainPoolItem();
//Log.v("","runs to obtain a enemy laser");
EnemyLaser el = new EnemyLaser(GameLevel.getInstance().pEnemyLaserTexture, x, y, angle, callingEnemy);
GameLevel.getInstance().attachChild(el);
return el;
}
@Override
protected EnemyLaser onAllocatePoolItem() {
// TODO Auto-generated method stub
//Log.v("", "Shouldn't run~");
return null;
}
}