-
God
fliping horizontal?
hi, ive been working on a fairly simple game... with a bunch of really annoying coding.... and now im trying to flip a character according to where he is pointing... and it is just driving me crazy....
could somebody please take a look at this for me, i just cant seem to get it.
thanks a bunch
-yeps
Last edited by yeps; 01-04-2010 at 09:58 PM.
-
Script kiddie
Just post the code, nobody wants to download a fla.
Since you've been on FK for nearly a year, I assume you already know that _xscale = -_xscale; is the code to flip a movie clip horizontally?
-
Senior Member
-
God
sorry...
hey... im sorry
i know how to flip it and every thing.... its just that this problem you may have to see...
um... i'll put a swf up on image shack for you though
and here is the code on the arm...
Code:
onClipEvent (enterFrame) {
if (_root.guy._xmouse<20){
_root.guy.gotoAndStop(1)
}
if (_root.guy._currentframe == 2){
this._x = 18
} else {
this._x = -18
}
if (angle2<-79) {
this._yscale = -100
_root.guy.gotoAndStop(2)
} else{
this._yscale = 100
_root.guy.gotoAndStop(1)
}
angle2 = Math.round(angle/Math.PI*180);
angle = Math.atan2(opp, adj);
opp = ((_root.guy._ymouse-this._y));
adj = -1*(_root.guy._xmouse-this._x);
this._rotation = -1*angle2;
}
http://img67.imageshack.us/my.php?image=guydh2.swf
i tried to use _xscale but sense the angle flips every time the body flips... it just keeps going back and fourth and i couldnt get it to stop... does that make sense?
-
Pumpkin Carving 2008
Originally Posted by Ray Beez
I do _xscale *= -1;
Yeah I was going to say, wouldn't that be more efficent because what if something prior changed the _xscale to like 30?
The 'Boose':
ASUS Sabertooth P67 TUF
Intel Core i7-2600K Quad-Core Sandy Bridge 3.4GHz Overclocked to 4.2GHz
8GB G.Skill Ripjaws 1600 DDR3
ASUS ENGTX550 TI DC/DI/1GD5 GeForce GTX 550 Ti (Fermi) 1GB 1GDDR5 (Overclocked to 1.1GHz)
New addition: OCZ Vertex 240GB SATA III SSD
WEI Score: 7.6
-
God
it wont work when i use xscale because when the body flips, the angle does too... and thats what determines weather to flip it or not...
-
Script kiddie
Yeps, it looks like the arm is inside the body movie clip. That'll be causing problems.
-
....he's amazing!!!
I think this might be a problem cause by movieclip._xmouse being relative, so when it flips, _xmouse reverses too.
Try nesting the whole thing inside another movieclip, and do your coding from there.
-
Please, Call Me Bob
oop, now i understand your problem, couldnt you do
body._xscale = body.arm._xscale;
?
then flip your arm, or do the coding vice versa
all you have to do is flip them both simeutaneously
this code ensures that the body's xscale is equal to that of the arm, and thus is pointing in the correct direction
-
M.D.
yeah, your coordinates are getting messed up when you flip on the _xscale, use the _root._xmouse instead of _root.guy._xmouse
so:
_root.guy._xscale = _root._xmouse < _root.guy._x ? 100 : -100
-
God
woah there mr malee, can you explain that code for me? i've seen one like it before but im not sure what it means
and then also... should i be determining whether to flip it or not by the angle? or should it maybe be the xmouse?
-
M.D.
its a simple conditional statement, just like writing
if(_root._xmouse < _root.guy._x){
_root.guy._xscale = 100
}else{
_root.guy._xscale = -100
}
this is what i changed, i also removed the two frames from the guy.
Code:
onClipEvent (enterFrame) {
_root.guy._xscale = _root._xmouse < _root.guy._x ? 100 : -100;
if (angle2<-79) {
this._yscale = -100
_root.guy.gotoAndStop(2)
} else{
this._yscale = 100
_root.guy.gotoAndStop(1)
}
angle2 = Math.round(angle/Math.PI*180);
angle = Math.atan2(opp, adj);
opp = ((_root.guy._ymouse-this._y));
adj = -1*(_root.guy._xmouse-this._x);
this._rotation = -1*angle2;
}
-
Please, Call Me Bob
yes but it's hard to learn new forms of writing immediately
the first thing i saw was a statement, not a conditional
which confused me a bit, but then i made sense of it, seems like such a strange way to write
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|