PDA

View Full Version : Rpg


mrownage
03-22-2008, 02:11 AM
Hi everyone, im making an RPG at the moment. I know action pretty well execpt one or two things, at the moment I am trying to get my player to change his weapon and armour.

My hero is made of parts (arms, leg, sword and so on) all the parts are movieclips so that I can change what they look like when you equip items the problem is that they dont change and I dont know why:

this was the first script i tried:
on (release) {
_root.sword.gotoAndStop(2);
}

and this is the second one i tried:
on (release) {
_parent(_root.hero)._root.sword.gotoAndStop(2);
}

but nothing works if anyone can help that would be great!

rrh
03-24-2008, 05:24 PM
trace() is your friend. If you aren't sure if you are addressing something correctly, try tracing it, and find out:
trace(_root.sword);

mrownage
03-24-2008, 09:28 PM
THANKS! ill try that out now :)

mrownage
03-25-2008, 10:51 AM
hey this might sound like a stupid question but is this how trace is ment to work?
trace(_root.club.gotoAndStop(1));

I dont think so but i might be wrong.

ASWC
03-25-2008, 01:40 PM
trace will output properties whatever they might be, so if you can get a value fom something, then you probably can trace it. In you example you are creating an action: trace(_root.club.gotoAndStop(1)); which is not gonna return a value of any type so trace will not show you anything valuable.

rrh
03-25-2008, 03:15 PM
Yeah, it doesn't directly solve your problem, but it can help you figure it out.
Like, you can try a bunch of things like this:
trace(_root.sword);
trace(_parent.sword);
trace(this.sword); and by seeing which ones, if any, trace what you're looking for.

If I try something like
_parent._parent.frank.joe.fred.gotoAndPlay(3)
and that's not working, the first thing I do is run
trace(_parent._parent.frank.joe.fred);
trace(_parent._parent.frank.joe)
trace(_parent._parent.frank)
trace(_parent._parent)
trace(_parent)
to see which ones are valid references and which aren't.

mrownage
03-26-2008, 10:07 AM
ya i tried doing what you said:

trace(_parent.hero.club);
trace(_parent.hero);
trace(_parent);

but all of them were undefined is, what should i do now?

rrh
03-26-2008, 01:02 PM
this._parent

_root.hero.club

How about those?

mrownage
03-26-2008, 08:49 PM
SWEET thanks alot I got it to work!!! Ill keep you posted if I have another problem but ya thanks heaps!

mrownage
03-27-2008, 10:47 AM
Hey everyone I got another problem, its to do with my battle system. Its a turn based game and I have buttons like attack and such, the problem is iv made a var called turn basically if its not your turn the button wont work, this is the code im using and I just dont see why it doesnt work. What happens is he will attack then turn will become false (I made a text box that tells me) but even when its fasle he can attack when its clicked on

turn = true;
this.stop();
attack.onRelease = function() {
if (turn=true){
turn = false;
_root.hero.gotoAndStop(2);

}
}

Any ideas?

killingdyl
03-27-2008, 02:13 PM
you got to switch around your actionscripts

this is what you have:
turn = true;
this.stop();
attack.onRelease = function() {
if (turn=true){
turn = false;
_root.hero.gotoAndStop(2);

}
}

this is what you need:
turn = true;
this.stop();
if(turn = true){
attack.onRelease = function() {
turn = false;
_root.hero.gotoAndStop(2);

}
}

tell me if that doesnt work

rrh
03-27-2008, 03:33 PM
I don't think that would work. It's better to have the "if" statement inside the function, in this case.

The source of the problem is this line:
if (turn=true){
it should be
if (turn==true){
One is assigning, the other is a test. Common mistake in people just starting out in programming.