3 Replies - 1758 Views - Last Post: 27 July 2008 - 10:48 PM

#1 cadeownz  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 31
  • Joined: 12-July 08

xScale make it take more than the default -- or ++

Posted 26 July 2008 - 05:45 PM

Hey,
I have a movieclip/rectangle 100x14 and its a health bar it works, when my character hits the enemy it decreases the health bar.. BUT i wont it to take more (or less) off than the default speed of -- lets say a specific amount of like 10 or something. Any help guys? heres the code for the enemy..
onClipEvent(enterFrame) {
if(_root.char.hitTest(this)){
_root.hp--;
}
}


see on line 3 its _root.hp--; i need the to make it take off a specific amount like _root.hp-20; or something any help guys?
thanks in advance..

Is This A Good Question/Topic? 0
  • +

Replies To: xScale make it take more than the default -- or ++

#2 BetaWar  Icon User is offline

  • #include "soul.h"
  • member icon

Reputation: 1167
  • View blog
  • Posts: 7,207
  • Joined: 07-September 06

Re: xScale make it take more than the default -- or ++

Posted 26 July 2008 - 10:03 PM

how about _root.hp -= 20; it will take off the specific amount (say 20) and everything there. If you want it to take off a rage try something like so:

onClipEvent(enterFrame){
  if(_root.char.hitTest(this)){
	var max_damamge:Number = 20;
	var min_damage:Number = 15;
	var damage:Number = (Math.rand()*(max_damage-min_damage))+min_damage;
	_root.hp -= damage;
  }
}


Where max damage is a number of the max amount of damage the enemy can do, and min damage is the min amount of damage that an account can do.

REALIZE - at this point this range includes decimals down quite far. As such your character can have a fraction of a hit pioint remaining.

If you want to make this whole numbers you could wrap the damage alculations in a Math.floor or Math.ciel to round up or down to the nearest integer.

Hope that helps.
Was This Post Helpful? 1
  • +
  • -

#3 cadeownz  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 31
  • Joined: 12-July 08

Re: xScale make it take more than the default -- or ++

Posted 27 July 2008 - 09:50 PM

OMG ur a legend thanx sooo much u js savd mi RPG game. THANX
Was This Post Helpful? 0
  • +
  • -

#4 BetaWar  Icon User is offline

  • #include "soul.h"
  • member icon

Reputation: 1167
  • View blog
  • Posts: 7,207
  • Joined: 07-September 06

Re: xScale make it take more than the default -- or ++

Posted 27 July 2008 - 10:48 PM

Just here to help. :D
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1