PDA

View Full Version : changing money value



fourthsword
December 29th, 2004, 07:14 PM
How do I change the value of the money I'm using in my game. Here's my code.



onClipEvent (enterFrame) {

if (_root.hero.hitTest (this)) {

_root.money++;
this._x = -50;
this._y = -50;

}

}

eiefai
December 29th, 2004, 11:17 PM
that code just change the position of the MC, i think that what you want, is to set a variable "money", you just have to put this on one layer of the main scene:

money=0;

if im wrong its beacuse i dont really understan what you want to say.



eiefai

fourthsword
December 29th, 2004, 11:24 PM
I have " money=0; " on the first frame as well. It works as it is but I want to create different money values.

smoothhabitat
December 29th, 2004, 11:38 PM
So, you have money++ which just adds 1 to money... you want to setup some constants:

SILVER=5;
GOLD=10;

and then add like this:

money+=SILVER;

when you hit a silver and:

money+=GOLD;

when you hit the gold.

Make sense?

fourthsword
December 30th, 2004, 10:25 AM
Thanks. I got it to work.