Newgrounds.com — Everything, By Everyone.

Checking login status…

USERNAME:

PASSWORD:

Logging in…

Logged in as:
.
Logging out…
Inbox My Account Log Out


Forum Topic: Circular Path

(191 views • 12 replies)

This topic is 1 page long.

<< < > >>
None

Nuggs

Reply To Post Reply & Quote

Posted at: 12/9/07 01:24 AM

Nuggs LIGHT LEVEL 18

Sign-Up: 12/17/05

Posts: 1,201

Mmmmk... I'm trying to make an object rotate around an ovular (sp?) path using only actionscript, but I'm having some problems

onClipEvent (load) {
	var time:Number = 0;
	var framePerSec:Number = 40;
	var radPerFrame:Number = 0;
}
onClipEvent (enterFrame) {
	framePerSec = parseFloat(_root.fps_timer.f.text);
	//_root.fps_timer.f.text is a text box that tells me the fps
	trace(typeof (framePerSec));
	//this returns number
	radPerFrame = (2*Math.PI)/(framePerSec*60);
	//conversion
	trace(typeof (radPerFrame));
	//this returns number
	time += radPerFrame;
	trace(typeof (time));
	//this returns number
	trace(time);
	//returns NaN
	_x += 2.25*Math.cos(time);
	_y += 2*Math.sin(time);
	//movement functions
}

Can anyone help? It doesn't seem to want to add radPerFrame to time... but all of the vars are numbers

Games|1|2|3| Movies|1|2|

BBS Signature

Happy

zenyara

Reply To Post Reply & Quote

Posted at: 12/9/07 02:10 AM

zenyara NEUTRAL LEVEL 10

Sign-Up: 06/17/05

Posts: 839

I'd do it using an array and make a trace editor for it where you click, click, click, click, click out your desired path, then trace and past to your array, then use speed=3 to travel through the array of x,y.

Easy and that way you can make any kind of path you like...

I'll do the code for you if you can't figure it out.


None

Vengeance

Reply To Post Reply & Quote

Posted at: 12/9/07 02:26 AM

Vengeance EVIL LEVEL 28

Sign-Up: 03/18/05

Posts: 5,040

I don't quite understand what you're trying to do... Explain a little better.

========|| WWWWWWWW>[-[Blog] - [Audio] - [Userpage] - [Flash] - [Last.fm]-]<WWWWWWWW ||========

BBS Signature

None

GustTheASGuy

Reply To Post Reply & Quote

Posted at: 12/9/07 05:42 AM

GustTheASGuy LIGHT LEVEL 08

Sign-Up: 11/02/05

Posts: 9,006

Elliptical you mean.

All you need to do is increment the radians and use sin/cos times its dimensions. I don't see where's the problem?

haXe AliceML Box2dLite Learn AS
#ngprogramming at irc.freenode.net
OVER NINE THOUSAAAAND!!!


None

Nuggs

Reply To Post Reply & Quote

Posted at: 12/9/07 12:10 PM

Nuggs LIGHT LEVEL 18

Sign-Up: 12/17/05

Posts: 1,201

I'm trying to make the time it takes for the object to make a complete rotation equal to 60 seconds, or any other value, but I'm getting a NaN when I try to add radPerSec to time

Games|1|2|3| Movies|1|2|

BBS Signature

None

GustTheASGuy

Reply To Post Reply & Quote

Posted at: 12/9/07 01:19 PM

GustTheASGuy LIGHT LEVEL 08

Sign-Up: 11/02/05

Posts: 9,006

Ohyea. Well then, there can only be a problem with the textbox.

haXe AliceML Box2dLite Learn AS
#ngprogramming at irc.freenode.net
OVER NINE THOUSAAAAND!!!


None

Nuggs

Reply To Post Reply & Quote

Posted at: 12/9/07 02:53 PM

Nuggs LIGHT LEVEL 18

Sign-Up: 12/17/05

Posts: 1,201

Here
This is my problem

Remove the black blur to see the difference
I need to use the fps at runtime in order to change how fast the object is moving or else it will be too slow, but whenever I use that, I get NaN

Games|1|2|3| Movies|1|2|

BBS Signature

None

GustTheASGuy

Reply To Post Reply & Quote

Posted at: 12/9/07 03:20 PM

GustTheASGuy LIGHT LEVEL 08

Sign-Up: 11/02/05

Posts: 9,006

Sigh. Your variable includes the text 'runtime FPS'. To not use display values to indicate state in your code. For good practice atleast.

haXe AliceML Box2dLite Learn AS
#ngprogramming at irc.freenode.net
OVER NINE THOUSAAAAND!!!


None

Nuggs

Reply To Post Reply & Quote

Posted at: 12/9/07 08:25 PM

Nuggs LIGHT LEVEL 18

Sign-Up: 12/17/05

Posts: 1,201

Oh.. that was just for the test... it is not in the real thing, disregard it please. If I pm you the real file will you help me?

Games|1|2|3| Movies|1|2|

BBS Signature

None

GustTheASGuy

Reply To Post Reply & Quote

Posted at: 12/10/07 08:29 AM

GustTheASGuy LIGHT LEVEL 08

Sign-Up: 11/02/05

Posts: 9,006

My point is a string with non-numeric characters evaluates to NaN.

haXe AliceML Box2dLite Learn AS
#ngprogramming at irc.freenode.net
OVER NINE THOUSAAAAND!!!


None

Nuggs

Reply To Post Reply & Quote

Posted at: 12/11/07 12:06 AM

Nuggs LIGHT LEVEL 18

Sign-Up: 12/17/05

Posts: 1,201

I know, parseFloat will only work if the words come after the number, but the text is not included in the actual version, it only displays the frames per second (without the text)

Games|1|2|3| Movies|1|2|

BBS Signature

None

GustTheASGuy

Reply To Post Reply & Quote

Posted at: 12/11/07 09:40 AM

GustTheASGuy LIGHT LEVEL 08

Sign-Up: 11/02/05

Posts: 9,006

In the file you posted if you remove the appended text part it works fine. Well after the delay of ten frames because you're pushing the framerate in an array for some reason.

haXe AliceML Box2dLite Learn AS
#ngprogramming at irc.freenode.net
OVER NINE THOUSAAAAND!!!


None

Nuggs

Reply To Post Reply & Quote

Posted at: 12/11/07 10:28 PM

Nuggs LIGHT LEVEL 18

Sign-Up: 12/17/05

Posts: 1,201

Ah I figured it out. Since the fps timer returned Nan for the first 9 frames, it added that infinite value to time. So when the fps timer returned real values, it could not add the finite numbers to the previous infinite ones.

Thanks so much for your help!

This was bugging me like crazy

Games|1|2|3| Movies|1|2|

BBS Signature

All times are Eastern Daylight Time (GMT -4) | Current Time: 11:15 PM

<< Back

This topic is 1 page long.

<< < > >>
You need a Grounds Gold Account to post on the NG BBS! If you don't have one, click here to sign up now! It's fast, free, and easy — and opens up tons of great NG features!