![]() |
![]() |
#11 | |
Process Fan
Join Date: Jun 2007
Posts: 32
|
Re: TF Flash Game
Quote:
looking at it right now you probably have a line that looks something like this that stops you from falling. if(this.hitTest(_root.ground)){ yspeed = 0; } because of that when it reports you are touching ground, you stop falling, but you also stop at the xy corespondents you actually hit the ground. now the better method of doing it, the relevant parts are as follow. do your speed calculations like you already are. before doing the hit detections add the forecast_x = this._x+xspeed; forecast_y = this._y+yspeed; lines of code, this sets forcast_x and forcast_y to where the player is going to be on the next frame. next you want to check if there inside something. that what this code is for. // floor control while (_root.lev.hitTest(forecast_x, forecast_y+this._height/2-1, true)) { forecast_y--; xspeed = 0; yspeed = 0; jumping = false; } // ceiling control while (_root.lev.hitTest(forecast_x, forecast_y-this._height/2, true)) { forecast_y++; yspeed = 0; } // left wall control while (_root.lev.hitTest(forecast_x-this._width/2+1, forecast_y, true)) { forecast_x++; xspeed = 0; } // right wall control while (_root.lev.hitTest(forecast_x+this._width/2, forecast_y, true)) { forecast_x--; xspeed = 0; } using the forcast_x and forcast_y values it checks where your going to land, and if it hits ground it continues to moved forcast_x and forcast_y untill they no longer get a negative hit test with the ground. then you just run. this._x = forecast_x; this._y = forecast_y; and that actually moves your character to the final location so you don't see them warping around. and that's it. in effect this causes your character to skate one pixel above the actual ground surface. you just plug in whatever code you need to execute when on the ground, to the ground hit while loop. this code makes solid platforms that bounce you out from all sides, you can make one sided ones with the same code, just make a second ground movie clip, call it something else, and only run the while loops that involve the landing on it check. you also need to check yspeed to make sure your actually falling to and not jumping up through it or you get odd warping. the only other option is to use what you have but increase the frame rate a tun. so you get more code executions at more locations. the only other change you may need to make is if your not using a speed variable, and just applying the movement directly to the player / screen. I know it'll work because I am currently using this method for my own non array based scrolling flash platform game. however, if you continue to insist it's not doable, then ok. eidt oh, duh. since your only moving players sprite along the y, and the stage when you move the x directions you may have to change the code a bit. basically, instead of this._x = forecast_x; try _root._x-=xspeed;
__________________
tfsnewworld.com <-- Updating Mondays, for now. Last edited by Tolka; 10-05-2008 at 05:58 AM. |
|
![]() |
![]() |
|
|