Need help with game

I made a platforms game but it needs some extras. Does anyone know how to add coins?

Are you serious? Sorry for me being rude but you got to post some indepth description or code/fla. Please think about this next time you post. And this time…

ok i dont know what u mean exacly but i hope i under stand u ok

u want to make money system? :stuck_out_tongue:

ok i hope thats it cause thats what ill teach u

  1. create a “Dynamic text box” and call it money
  2. draw a coin and make it a movie clip (no matter what u call it)

now give the coin these actions:

 onClipEvent(enterFrame){
       if (_root.charname.hitTest(this)){
       _root.money += 1;
      this._x = -500;
      this._y = -500;
      }
      }

now put this action in the frame:


_root.money = 0;

and that should be it :slight_smile:

That might work for a short game, but in a long one keeping the coins around like that might cause trouble. I suggest making a function called loadCoins that uses attachMovie() to load it from the library. Then unloadMovie() when you hitTest it. Look up those three functions (attachMovie, unloadMovie, hitTest), and then come back if you need help.

yeah… tho, Nich, not sure about needing a function… or to load them, or needing to call it loadCoins.

try, labelling all coins, coin0, coin1 etc…
if you have no coins in you game yet put this on the frame:


//
//Specify how many coins
var numCoins:Number = 67; //how many coins
/* 
or
use as to count coins
*/
var numCoins:Number = 0;
while(_root["coin"+numCoins]){
numCoins++;
}
//
//
for(var i:Number = 0; i<numCoins; i++){
_root["coin"+i].onEnterFrame = function(){
if(this.hitTest(char)){
score++;
trace(score);
this.unloadMovie();
}
}
}

if you already DO have coins in you game… on the first frame of the COIN MC, put this code(although, you can use this even if you dont have any coins on the stage at the moment)…


this._name = "coin"+_root.numCoins++;</

then on the frame of your movie


var numCoins:Number = 0;
setCoins = setInterval(function(){
for(var i:Number = 0; i<numCoins; i++){
_root["coin"+i].onEnterFrame = function(){
if(this.hitTest(char)){
score++;
trace(score);
this.unloadMovie();
}
}
}
clearInterval(setCoins);
}, 10);

let me know if this works… I just quickly typed it up in the little box lol, so I couldnt see half of what I wrote, and i cbf rechecking right now;)

while(_root["coin"+numCoins]){
numCoins++;
}

I’m not sure this would work…

lol… trust me I use that plenty:) And I know my stuff:lol: jk;)

Well, if you have time and wouldn’t mind explaining how, or pm me to now lead this thread off topic… It just seems to me it would be in infinate loop because you’re not actually comparing anything…

Oh, and I realise you know your stuff, I’ve been through your site and there is some pretty solide stuff on there.

lol. basically… if theres an object on the stage, it will return a value. like say if you wanted to see if something’s true, you only need: if(something) rather than running a strict comparison, this will check if something exists, != 0, != false etc… otherwise something will be returned as true. So basically if something exists it will return as _level0.whatever, thus, being true. When there’s no more left, it will die:)

Hope thaT clears it up:thumb: