Have lifes in AS

  • Jummm
  • Novice
  • Novice
  • Jummm
  • Posts: 17

Post 3+ Months Ago

Im making a mouse mouse game, and i was wondering, say i have a text with the intens name of "lifes" and it has the number 3 in it, how would i make it so if my mouse (mouse movieclip is called mouse) hits the walls (called walls)

lifes gets -1, and if lifes reachs 0, it goes and plays frame, say 150? ive seen it before, help anyones?
  • Anonymous
  • Bot
  • No Avatar
  • Posts: ?
  • Loc: Ozzuland
  • Status: Online

Post 3+ Months Ago

  • CyberSorcerer
  • Newbie
  • Newbie
  • CyberSorcerer
  • Posts: 6
  • Loc: Las Vegas

Post 3+ Months Ago

Hello Jummm

If you are going to name something on the stage that you are going to control through actionscript, you should have a string in front of it first (etc a1, a2, b1), with a number you run into problems sometimes with actionscript mistaking it for a integer instead of an instance name for a movieclip.

CyberSorcerer
  • classified
  • Expert
  • Expert
  • User avatar
  • Posts: 540
  • Loc: Bahrain

Post 3+ Months Ago

read about hit test .

------------

as in for life ...

declare variable ..

var life:Number = 3 ;

then for each of hit test is true >>> life -=1 ;
  • IceCold
  • Guru
  • Guru
  • User avatar
  • Posts: 1254
  • Loc: Ro

Post 3+ Months Ago

Code: [ Select ]
this.onEnterFrame = function()
{
if (mouse.hitTest(wall))
{
  var nLives = Number(lifes.text);
  nLives --;
  lifes.text = nLives;
  if (nLives == 0)
  {
    delete onEnterFrame;
    gotoAndPlay(150);
  }
}
}
  1. this.onEnterFrame = function()
  2. {
  3. if (mouse.hitTest(wall))
  4. {
  5.   var nLives = Number(lifes.text);
  6.   nLives --;
  7.   lifes.text = nLives;
  8.   if (nLives == 0)
  9.   {
  10.     delete onEnterFrame;
  11.     gotoAndPlay(150);
  12.   }
  13. }
  14. }
  • classified
  • Expert
  • Expert
  • User avatar
  • Posts: 540
  • Loc: Bahrain

Post 3+ Months Ago

IceCold wrote:
Code: [ Select ]
this.onEnterFrame = function()
{
if (mouse.hitTest(wall))
{
  var nLives = Number(lifes.text);
  nLives --;
  lifes.text = nLives;
  if (nLives == 0)
  {
    delete onEnterFrame;
    gotoAndPlay(150);
  }
}
}
  1. this.onEnterFrame = function()
  2. {
  3. if (mouse.hitTest(wall))
  4. {
  5.   var nLives = Number(lifes.text);
  6.   nLives --;
  7.   lifes.text = nLives;
  8.   if (nLives == 0)
  9.   {
  10.     delete onEnterFrame;
  11.     gotoAndPlay(150);
  12.   }
  13. }
  14. }


simple and neat ...

Post Information

  • Total Posts in this topic: 5 posts
  • Users browsing this forum: No registered users and 17 guests
  • You cannot post new topics in this forum
  • You cannot reply to topics in this forum
  • You cannot edit your posts in this forum
  • You cannot delete your posts in this forum
  • You cannot post attachments in this forum
 
 

© 1998-2014. Ozzu® is a registered trademark of Unmelted, LLC.