Web Design Forum: Make movieClip follow that of another - Web Design Forum

Jump to content

WDF
WDF Premium Memberships Reseller Hosting
Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Make movieClip follow that of another Rate Topic: -----

#1 User is offline   AdamConder 

  • Dedicated Member
  • PipPip
  • View gallery
  • Group: Members
  • Posts: 205
  • Joined: 18-May 09
  • Reputation: 9
  • Gender:Male
  • Location:Newcastle, UK
  • Experience:Intermediate
  • Area of Expertise:Coder

Posted 04 January 2011 - 07:17 PM

Hiya, I'm creating a game for university and I've got zombies on a stage. I want them to have a health bar that follows the zombie.

I've added it to the stage however it's not following it and it needs to be added at the x and y position of the zombie. (using math.random)

Anyway I can set the x and y to that of the zombie and make it follow it?

		public function iceZombieSpawn(e:TimerEvent) {
			var health:Number = 100; // set zombies health to 100
			iceZombie = new IceZombie(Math.random()*stage.stageWidth, -100); // Create new ice zombie at random x position (width, height, health, hitCount)
			IceZombie.spawnCount += 1; // increment count by 1 for each spawn using global variable (IceZombie refering to class)		
			iceZombie.name = "iceZombie"+IceZombie.spawnCount; // assign name to zombie
			iceZombieContainer.addChild(iceZombie); // Add zombie to container
			trace(iceZombie.name); // trace name of zombie
			trace("     Health: " + iceZombie.health); // trace current health 
			zombieHealth = new ZombieHealth(iceZombie.x, iceZombie.y); // create new health bar
			iceZombieContainer.addChild(zombieHealth); // add health bar to container
		}


That's the spawning but the health bar won't appear, it works if I put in fixed coordinates.
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users