0 Replies - 3831 Views - Last Post: 05 July 2012 - 12:57 PM

#1 Ravenhawke  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 1
  • Joined: 05-July 12

scale movieclips (enemies) added to stage - close=bigger far=smaller

Posted 05 July 2012 - 12:57 PM

I am creating a game, mostly for learning, but its also fun. I am adding enemies to the stage, ships, and i want them to sail across, which they do. But I don't know how to make them look smaller if they are farther away (higher on the stage) or big if they are close (lower on the stage) help? thanks in advance.

Here is my ship class code:

package{
    import flash.display.Sprite;
	import flash.display.Graphics;
	import flash.text.TextField;
	import flash.display.MovieClip;
 
    public class Enemy extends MovieClip{
		private var health_txt:TextField;
		private var health:int;
		private var speed_x:Number;
		private var speed_y:Number;
		private var scale_x:Number;
		private var scale_y:Number;

        public function Enemy() {
			health = 2;
			speed_x = -1.5;
    		speed_y = 0;
			addGalleon();
			draw();
        }
		
		private function addGalleon():void{
			var newShip:testShip = new testShip();
			this.addChild(newShip);
		}
		
		private function draw():void {		
			health_txt = new TextField();
			health_txt.height = 20; health_txt.width = 15;
			health_txt.textColor = 0xffffff;
			health_txt.x = 40;
			health_txt.y = -40;
			health_txt.text = health + "";
			addChild(health_txt);
		}
		 
		public function update():void {
			x += speed_x;
			y += speed_y;
		}
		public function updateHealth(amount:int):int {
			health += amount;
			health_txt.text = health + "";
			return health;
		}
    }
}



Is This A Good Question/Topic? 0
  • +

Page 1 of 1