A Flash Developer Resource Site

Results 1 to 13 of 13

Thread: fliping horizontal?

  1. #1
    God yeps's Avatar
    Join Date
    Dec 2005
    Location
    :noitacoL
    Posts
    660

    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.

  2. #2
    Script kiddie VENGEANCE MX's Avatar
    Join Date
    Jun 2004
    Location
    England
    Posts
    2,590
    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?
    http://www.birchlabs.co.uk/
    You know you want to.

  3. #3
    Senior Member Ray Beez's Avatar
    Join Date
    Jun 2000
    Posts
    2,793
    I do _xscale *= -1;

  4. #4
    God yeps's Avatar
    Join Date
    Dec 2005
    Location
    :noitacoL
    Posts
    660

    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?

  5. #5
    Pumpkin Carving 2008 ImprisonedPride's Avatar
    Join Date
    Apr 2006
    Location
    Grand Rapids MI
    Posts
    2,378
    Quote 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

  6. #6
    God yeps's Avatar
    Join Date
    Dec 2005
    Location
    :noitacoL
    Posts
    660
    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...

  7. #7
    Script kiddie VENGEANCE MX's Avatar
    Join Date
    Jun 2004
    Location
    England
    Posts
    2,590
    Yeps, it looks like the arm is inside the body movie clip. That'll be causing problems.
    http://www.birchlabs.co.uk/
    You know you want to.

  8. #8
    ....he's amazing!!! lesli_felix's Avatar
    Join Date
    Nov 2000
    Location
    London UK
    Posts
    1,506
    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.

  9. #9
    Please, Call Me Bob trogdor458's Avatar
    Join Date
    Aug 2006
    Location
    Pensacola, FL
    Posts
    915
    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

  10. #10
    M.D. mr_malee's Avatar
    Join Date
    Dec 2002
    Location
    Shelter
    Posts
    4,139
    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
    lather yourself up with soap - soap arcade

  11. #11
    God yeps's Avatar
    Join Date
    Dec 2005
    Location
    :noitacoL
    Posts
    660
    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?

  12. #12
    M.D. mr_malee's Avatar
    Join Date
    Dec 2002
    Location
    Shelter
    Posts
    4,139
    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;
    }
    lather yourself up with soap - soap arcade

  13. #13
    Please, Call Me Bob trogdor458's Avatar
    Join Date
    Aug 2006
    Location
    Pensacola, FL
    Posts
    915
    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
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center