Copy link to clipboard
Copied
I want to make an RPG game which uses turn-based battles. The problem is that my animations aren't playing when a specific button is pressed.
When the user presses the button labeled "attack", it will set the variable (ryu_action = 1).
On the next frame my animation will detect the variable and set it's "Alpha" value accordingly. My code for the Movie Clip object is the following:
onClipEvent (enterFrame) {
if (_root.action_ryu == 1) {
this._Alpha = 100;
this.gotoAndPlay(4)
_root.Ryu._Alpha = 0;
} else {
_root.Ryu_Attack._Alpha = 0;
}
}
What I wanted was for multiple layers with objects that play one single animation in them overlapping a certain area. They will all hide/unhide themselves according to what action the user makes.
The problem I have here is that when the user presses the "Attack" button, the movie clip will follow the "gotoAndPlay" command and got to the fourth frame within the Movie Clip but it will get stuck on the fourth frame, not moving at all.
There is a "stop()" command placed on frame 1 of the movie clip but it's in it's own keyframe and shouldn't affect the rest of the animation within the movie clip.
My mentor has alerady told me that the code should be correct but it's just not running right for some reason.
I am using Actionscrip 2.0 on Adobe Flash CS3 Professional with a Windows XP computer.
Copy link to clipboard
Copied
1. you should have no code attached to objects. assign your objects instance names (eg, mc) and use those names in your code.
2. that code should not be in an enterframe loop.
if(_root.action_ryu==1){
mc._alpha=100; // not _Alpha
mc.gotoAndPlay(4);
_root.Ryu._alpha=0;
} else {
_root.Ryu_Attack._alpha=0;
}
Copy link to clipboard
Copied
What clip event should I use? Also changing the spelling of "Alpha" to "alpha" doesn't really help nor does giving it an instance name help. Also I've tested it with instance names before only to get the same result
Copy link to clipboard
Copied
1. no clip event should be used
2. did you assign the movieclip an instance name (in the properties panel)?
Copy link to clipboard
Copied
I assigned the movieclip instance via the properties panel. Also upon not using "onClipEvent" I get the following error:
"Statement must appear within on/onClipEvent handler"
Copy link to clipboard
Copied
So is what you want to happen, when you click attack the animation occurs?
try:
on(release){
tellTarget("targetName"){
gotoAndPlay(desiredFrame);
}
}
Copy link to clipboard
Copied
No that's not it, since it's going to be a turn based RPG game, I want it so that the user will click on the button, a few frames will go by with the user making other moves (clicking on buttons for a different character, checking the special move menu etc.) and then the animation will play when it's supposed to.
Copy link to clipboard
Copied
again, you should have not code attached to objects. attach your code to the frame that contains your object.
Find more inspiration, events, and resources on the new Adobe Community
Explore Now