-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathmemory.js
63 lines (56 loc) · 1.78 KB
/
memory.js
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
/*
removes the asteroid from the array and the sprite from the screen
must do both to avoid memory leak
*/
function removal(array,object){
let index = array.indexOf(object);
object.remove();
array.splice(index,1);
}
function cullObjects(){
asteroidGroup.cull(50, (object) => {
let index = asteroids.indexOf(object);
object.remove();
asteroids.splice(index,1);
});
trackerGroup.cull(50, (object) => {
console.log(object)
let index = trackers.indexOf(object);
object.remove();
trackers.splice(index,1);
});
bulletGroup.cull(10, (object) => {
console.log(object)
let index = allBullets.indexOf(object);
object.remove();
allBullets.splice(index,1);
});
}
class Animation{
static preload(){
this.frameDelay = 1;
this.idleAni = loadAni("idle",'assets/hitpurple1.png',{
frameSize: [90,90],frames: 1
})
this.hitAni = loadAni("hit",'assets/hitpurple1.png',{
frameSize:[90,90], frames: 4
})
this.shieldedAnim = loadAni("shield",'assets/purpleshield.png',{
frames: 1
})
this.bulletAni = loadAni("bulletAni","assets/spr_bullet_strip.png",{
frames: 3
})
this.enemyBulletAni = loadAni("enemyBulletAni","assets/enemybullet.png",{
frames: 1
})
this.cannonAni = loadAni("cannonAni","assets/spr_bullet_strip02.png",{
frames: 3
})
//this.expAni = loadImage("assets/Exp1.png")
//this.healthAni= loadImage("assets/health_potion.png")
//this.asteroidAni = loadImage("assets/asteroid.png")
//this.trackerAni = loadImage("assets/bugb.png")
//this.shooterAni = loadAni("assets/bird.png")
}
}