-
Notifications
You must be signed in to change notification settings - Fork 0
/
PlayerLaserPool.java
66 lines (51 loc) · 1.9 KB
/
PlayerLaserPool.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
59
60
61
62
63
64
65
66
package mkat.apps.spacewars;
import org.andengine.util.adt.pool.GenericPool;
import mkat.apps.spacewars.GameLevel;
import android.util.Log;
public class PlayerLaserPool extends GenericPool<PlayerLaser> {
/* The pool constructor assigns the necessary objects needed to
* construct sprites */
public PlayerLaserPool(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 PlayerLaser onAllocatePoolItem(Player callingPlayer, float x, float y) {
//Log.v("","runs to allocate a player laser");
PlayerLaser pl = new PlayerLaser(GameLevel.getInstance().pPlayerLaserTexture, callingPlayer, x, y);
//GameLevel.getInstance().attachChild(pl);
return pl;
}
//GameLevel.getInstance().attachChild(pl);
//Log.v("something", "enemy created with modifiers and listeners");
@Override
protected void onHandleRecycleItem(PlayerLaser pItem){
super.onHandleRecycleItem(pItem);
pItem.clearEntityModifiers();
pItem.clearUpdateHandlers();
pItem.setVisible(false);
pItem.reset();
GameLevel.getInstance().PlayerLaser = pItem;
//GameLevel.getInstance().recycleBullet = true;
//Log.v("","recycled a laser icon3");
}
public synchronized PlayerLaser obtainPoolItem(Player callingPlayer, float x, float y) {
// TODO Auto-generated method stub
//super.obtainPoolItem();
//Log.v("","runs to obtain a player laser");
PlayerLaser pl = null;
if (GameLevel.getInstance().firePower == false) {
pl = new PlayerLaser(GameLevel.getInstance().pPlayerLaserTexture, callingPlayer, x, y);
} else {
pl = new PlayerLaser(GameLevel.getInstance().pPlayerLaserTexture2, callingPlayer, x, y);
}
GameLevel.getInstance().attachChild(pl);
return pl;
}
@Override
protected PlayerLaser onAllocatePoolItem() {
// TODO Auto-generated method stub
return null;
}
}