The Enchanted Cave 2
Delve into a strange cave with a seemingly endless supply of treasure, strategically choos
4.39 / 5.00 38,635 ViewsGhostbusters B.I.P.
COMPLETE edition of the interactive "choose next panel" comic
4.09 / 5.00 15,161 ViewsIf I make a movie clip set of sprites and say I program him to go left, but want him to go right and face right too and he only faced left before, what could I do to make it so he faces right with out completely remaking the sprites movie clips? Could I just copy the main sprites movie clip and go inside it and put it at the end in the opposite direction?
smiles
At 4/25/09 05:43 PM, jackkyboy wrote: If I make a movie clip set of sprites and say I program him to go left, but want him to go right and face right too and he only faced left before, what could I do to make it so he faces right with out completely remaking the sprites movie clips? Could I just copy the main sprites movie clip and go inside it and put it at the end in the opposite direction?
You can edit the _xscale property of a MovieClip.
For example, if you're MovieClip's instance name was "player", you would use the code:
player._xscale = -100
Then, to reset him, use (notice I used a negative symbol before):
player._xscale = 100
Tell me if this helps. If not, I'll try to help further.
okay well here is part of my code and his instance name is player, would this be correct because It most certainly did not reverse the clip. and didnt do anything
if(Key.isDown(Key.LEFT)){
_x-=speed;
player._xscale=100;
}
smiles
At 4/25/09 06:04 PM, jackkyboy wrote: if(Key.isDown(Key.LEFT)){
_x-=speed;
player._xscale=100;
}
If he moves left when you press left, then remove the 'player.' bit. That bit is needed for referencing, when you're coding on the main timeline for example. Yet, where you're placing the code does not need this referencing. You just need the '_xscale'.
Doomsday-One, working on stuff better than preloaders. Marginally.
Okay it works now, thanks so much! now I can get farther on my game!
smiles
Hmm now, even when I let go of the key, he still does the animation for walking! what should I do now.
here is a tidbit of the code
if(Key.isDown(Key.LEFT)){
_x-=speed;
_xscale=100;
_root.player.gotoAndStop(2);
}
smiles
I said -100 reverses him and 100 puts him back to normal.
Yeah he turns fine, It's just he just walks now and doesnt stop
smiles
At 4/25/09 06:15 PM, jackkyboy wrote: if(Key.isDown(Key.LEFT)){
_x-=speed;
_xscale=100;
_root.player.gotoAndStop(2);
}
else {
_root.player.gotoAndStop(1)
}
...Or whatever frame the stationary animation is on.
Doomsday-One, working on stuff better than preloaders. Marginally.
well it works, it jsut doesnt show the animation for the running, he just slides on the ground instead of any running sequence.
smiles
if(Key.isDown(Key.LEFT)){
_x-=speed;
_xscale=100;
_root.player.gotoAndStop(2);
} else {
_root.player.gotoAndStop(1);
}
I think you need to learn some more coding, my friend.
Doomsday-One, working on stuff better than preloaders. Marginally.
I would suggest going and taking a look at some movement tutorials
Also, judging by your problems it doesn't look like your player mc does actually have the instance name "player" - maybe you should double check that
At 4/25/09 06:39 PM, Doomsday-One wrote: if(Key.isDown(Key.LEFT)){
_x-=speed;
_xscale=100;
_root.player.gotoAndStop(2);
} else {
_root.player.gotoAndStop(1);
}
That is the exact code I put in! and It just won't play the clip.
smiles
At 4/25/09 06:41 PM, Captainhams wrote: Also, judging by your problems it doesn't look like your player mc does actually have the instance name "player" - maybe you should double check that
Indeed. Try removing the parts of the code which say '_root.player.'
Doomsday-One, working on stuff better than preloaders. Marginally.
Hmm that did not do it either.
heres the entire code so far.
onClipEvent(load){
var ground:MovieClip=_root.ground;
var grav:Number=0;
var gravity:Number=2;
var speed:Number=10;
var maxJump:Number=-18;
var touchingGround:Boolean=false;
_root.ATTACKONE = 65;
_root.ATTACKTWO = 83;
}
onClipEvent(enterframe){
_y+=grav;
grav+=gravity;
while(ground.hitTest(_x,_y,true)){
_y-=gravity;
grav=0;
}
if(ground.hitTest(_x,_y+1,true)){
touchingGround=true;
}else{
touchingGround=false;
}
if(Key.isDown(Key.RIGHT)){
_x+=speed;
_xscale=-100;
gotoAndStop(2);
}else{
gotoAndStop(1);
}
if(Key.isDown(Key.LEFT)){
_x-=speed;
_xscale=100;
gotoAndStop(2);
}else{
gotoAndStop(1);
}
if(Key.isDown(Key.UP)&&
touchingGround){
grav=maxJump;
}
}
smiles
At 4/25/09 06:56 PM, jackkyboy wrote: if(Key.isDown(Key.RIGHT)){
_x+=speed;
_xscale=-100;
gotoAndStop(2);
}else{
gotoAndStop(1);
}
if(Key.isDown(Key.LEFT)){
_x-=speed;
_xscale=100;
gotoAndStop(2);
}else{
gotoAndStop(1);
}
Oh, of course.
Try this:
if(Key.isDown(Key.RIGHT)){
_x+=speed;
_xscale=-100;
gotoAndStop(2);
}else if(Key.isDown(Key.LEFT)){
_x-=speed;
_xscale=100;
gotoAndStop(2);
}else{
gotoAndStop(1);
}
Basically, it was going to frame 1 if the left key wasn't down or the right key wasn't down. So it would only play 'walking' if both were down. I used 'else' statements to stop that.
Now the code checks whether the right key is down. If it isn't, it checks the left. If that isn't either, it goes to the standing animation.
Doomsday-One, working on stuff better than preloaders. Marginally.
Okay! thanks so much I just did some editing to make it work on the other key, and It did it, Thanks so Much!
smiles
OKAY I SWEAR THIS IS THE LAST QUESTION, I have attack clips too, Two to be exact, and I was review a different engine I had. and it said to put
_root.ATTACKONE = 65;
_root.ATTACKTWO = 83;
if(Key.isDown(_root.ATTACKONE)){
_root.player.gotoAndStop(4);
}
if(Key.isDown(_root.ATTACKTWO)){
_root.player.gotoAndStop(5);
}
on the ClipEvent Player
and When I try to use it. nothing happens.
smiles