free hit counters
TF Flash Game - The Process Forum
The Process Forum  

Go Back   The Process Forum > Content Forums > Transformation

Inflation and Process ClipsProcess Productions Store Inflation and Process Clips

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
Unread 10-05-2008   #11
Tolka
Process Fan
 
Tolka's Avatar
 
Join Date: Jun 2007
Posts: 32
Re: TF Flash Game

Quote:
Originally Posted by monomonkey View Post
To all: Really, I apologize for the hit detection but there's really nothing I can do about it at this point. I imagine running the video at 60 frames per second would help a bit, but then I'd have to go back and revise everything from the ground up. I doubt even the basic movement code works outside of 30fps.
ok, let me be really really specific then. the reason your having problems with landing inside things is because of how flash handles code, it runs the whole code on a per frame basses, so, because your charictor dose not move across all pixies but actual moves several depending on speed when it runs the calculations you can be inside a platform.
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.
Tolka is offline   Reply With Quote
 


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -7. The time now is 01:16 PM.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2025, vBulletin Solutions, Inc.