From d7b0f93a41717aa1c39caf85de3d9f7630284ef2 Mon Sep 17 00:00:00 2001 From: Bram van der Veen <96aa48@gmail.com> Date: Sat, 26 Jul 2014 20:30:12 +0200 Subject: [PATCH] Did several tweaks for less memory usage and fixed StoreArrows.hx not working correctly. --- project.xml | 5 ++--- src/Boss.hx | 12 ++++++------ src/EnemyBullet.hx | 2 ++ src/Lives.hx | 4 ++++ src/Pickup.hx | 22 +++++++++++----------- src/StoreArrows.hx | 26 ++++++-------------------- 6 files changed, 31 insertions(+), 40 deletions(-) diff --git a/project.xml b/project.xml index 5aafdb3..49f7f2f 100644 --- a/project.xml +++ b/project.xml @@ -4,7 +4,7 @@ - + @@ -12,10 +12,9 @@ - + - diff --git a/src/Boss.hx b/src/Boss.hx index 144e824..f2001ba 100644 --- a/src/Boss.hx +++ b/src/Boss.hx @@ -15,7 +15,7 @@ class Boss extends Entity { public function new (clr:Int) { color = clr; - currentSprite = sprites[color]; + currentSprite = new Image(sprites[color]); currentSprite.scale = 8; currentSprite.smooth = false; @@ -108,11 +108,11 @@ class Boss extends Entity { private var currentSprite:Image; - private var sprites:Array = [ - new Image("graphics/ufoGreen.png"), - new Image("graphics/ufoBlue.png"), - new Image("graphics/ufoRed.png"), - new Image("graphics/ufoYellow.png") + private var sprites:Array = [ + "graphics/ufoGreen.png", + "graphics/ufoBlue.png", + "graphics/ufoRed.png", + "graphics/ufoYellow.png" ]; private var color:Int; diff --git a/src/EnemyBullet.hx b/src/EnemyBullet.hx index a8a1f79..251e810 100644 --- a/src/EnemyBullet.hx +++ b/src/EnemyBullet.hx @@ -22,6 +22,8 @@ class EnemyBullet extends Entity { graphic = sprite[0]; type = "enemybullet"; + + layer = -4; } public override function update() { diff --git a/src/Lives.hx b/src/Lives.hx index 665e3b7..681be1f 100644 --- a/src/Lives.hx +++ b/src/Lives.hx @@ -18,6 +18,10 @@ class Lives extends Entity { maxDamage = Save.load().ship_type + Save.load().ship_color; + if (Save.load().ship_type == 1) {maxDamage++;}; + + trace(maxDamage); + liveBar = Image.createRect(Math.floor(baseSprite.width * .75), 10, 0x00FF00); liveBar.y += 65; diff --git a/src/Pickup.hx b/src/Pickup.hx index 2d09b6f..836bc0c 100644 --- a/src/Pickup.hx +++ b/src/Pickup.hx @@ -28,7 +28,7 @@ class Pickup extends Entity { rand = Math.floor(Math.random() * 3); - graphic = currentSprite = sprites[randType][rand]; + graphic = currentSprite = new Image(sprites[randType][rand]); if (Math.random() > .5) turnSpeed = -1 * (Math.random() * 4); @@ -80,21 +80,21 @@ class Pickup extends Entity { } - private var sprites:Array> = [ + private var sprites:Array> = [ [ - new Image("graphics/shield_bronze.png"), - new Image("graphics/shield_silver.png"), - new Image("graphics/shield_gold.png") + "graphics/shield_bronze.png", + "graphics/shield_silver.png", + "graphics/shield_gold.png" ], [ - new Image("graphics/things_bronze.png"), - new Image("graphics/things_silver.png"), - new Image("graphics/things_gold.png") + "graphics/things_bronze.png", + "graphics/things_silver.png", + "graphics/things_gold.png" ], [ - new Image("graphics/star_bronze.png"), - new Image("graphics/star_silver.png"), - new Image("graphics/star_gold.png") + "graphics/star_bronze.png", + "graphics/star_silver.png", + "graphics/star_gold.png" ] ]; diff --git a/src/StoreArrows.hx b/src/StoreArrows.hx index 34855c6..726dd32 100644 --- a/src/StoreArrows.hx +++ b/src/StoreArrows.hx @@ -7,10 +7,10 @@ import StoreItem; class StoreArrows extends Entity { - public function new(x:Float, y:Float, type:Int) { + public function new(x:Float, y:Float, z:Int) { super(x - 230, y); - which = type; - if (type != 4) + which = z; + if (z != 4) currentItem = 1; else currentItem = 0; @@ -43,20 +43,20 @@ class StoreArrows extends Entity { arrowLeft.visible = false; else arrowLeft.visible = true; + if (currentItem == storeItems[which].items[which].length - 1) arrowRight.visible = false; else arrowRight.visible = true; if (Input.mouseReleased) { - if (Input.mouseY > this.top && Input.mouseY < this.bottom) { if (Input.mouseX > this.left && Input.mouseX < this.left + 100) { - storeItems[which].goLeft(); + storeItems[(storeItems.length - 1) - which].goLeft(); if (currentItem != 0) currentItem--; } if (Input.mouseX < this.right && Input.mouseX > this.right - 100) { - storeItems[which].goRight(); + storeItems[(storeItems.length - 1) - which].goRight(); if (currentItem != storeItems[which].items[which].length - 1) currentItem++; } } @@ -64,20 +64,6 @@ class StoreArrows extends Entity { } - private function onTouch(touch:Touch) { - var storeItems:Array = []; - this.scene.getClass(StoreItem, storeItems); - - if (touch.y > this.top && touch.y < this.bottom) { - if (touch.x > this.left && touch.x < this.left + 100) { - storeItems[which].goLeft(); - } - if (touch.x < this.right && touch.x > this.right - 100) { - storeItems[which].goRight(); - } - } - } - private var arrowLeft:Image; private var arrowRight:Image; private var which:Int;