ok so usually when I want to move an object at a consistent speed no matter what the frame rate, I will use this equation:
ActionScript Code:
[LEFT][COLOR=#000000]**var**[/COLOR] timeDiff:[COLOR=#0000FF]Number[/COLOR];
[COLOR=#000000]var[/COLOR] lastTime:[COLOR=#0000FF]Number[/COLOR] = [COLOR=#0000FF]getTimer[/COLOR]COLOR=#000000[/COLOR];
[COLOR=#0000FF]public[/COLOR] [COLOR=#000000]function[/COLOR] animationLoopCOLOR=#000000[/COLOR][COLOR=#000000]{[/COLOR]
timeDiff=[COLOR=#0000FF]getTimer[/COLOR][COLOR=#000000]([/COLOR][COLOR=#000000])[/COLOR] - lastTime;
lastTime+= timeDiff;
myObject.[COLOR=#000080]x[/COLOR] += [COLOR=#000080]10[/COLOR] * timeDiff / [COLOR=#000080]1000[/COLOR];
[COLOR=#000000]}[/COLOR]
[/LEFT]
however I have an object (black hole) that when active sucks all other object in towards it, furthermore when the objects gravitate toward the black hole, they rotate at an angle, here is the code for that:
//for object gravitating to the black hole
ActionScript Code:
[LEFT][COLOR=#000000]var[/COLOR] dx:[COLOR=#0000FF]Number[/COLOR] = [COLOR=#000000]([/COLOR]theBlackHole.[COLOR=#000080]x[/COLOR] - [COLOR=#0000FF]this[/COLOR].[COLOR=#000080]x[/COLOR][COLOR=#000000])[/COLOR];
[COLOR=#000000]var[/COLOR] dy:[COLOR=#0000FF]Number[/COLOR] = [COLOR=#000000]([/COLOR]theBlackHole.[COLOR=#000080]y[/COLOR] - [COLOR=#0000FF]this[/COLOR].[COLOR=#000080]y[/COLOR][COLOR=#000000])[/COLOR];
[COLOR=#000000]var[/COLOR] radian:[COLOR=#0000FF]Number[/COLOR] = [COLOR=#0000FF]Math[/COLOR].[COLOR=#0000FF]atan2[/COLOR]COLOR=#000000[/COLOR];
[COLOR=#0000FF]this[/COLOR].[COLOR=#000080]rotation[/COLOR] = radian * [COLOR=#000080]180[/COLOR]/[COLOR=#0000FF]Math[/COLOR].[COLOR=#0000FF]PI[/COLOR];
[COLOR=#000000]var[/COLOR] easeX:[COLOR=#0000FF]Number[/COLOR] = [COLOR=#000000]([/COLOR]theBlackHole.[COLOR=#000080]x[/COLOR] - [COLOR=#0000FF]this[/COLOR].[COLOR=#000080]x[/COLOR][COLOR=#000000])[/COLOR] * .[COLOR=#000080]01[/COLOR];
[COLOR=#000000]var[/COLOR] easeY:[COLOR=#0000FF]Number[/COLOR] = [COLOR=#000000]([/COLOR]theBlackHole.[COLOR=#000080]y[/COLOR] - [COLOR=#0000FF]this[/COLOR].[COLOR=#000080]y[/COLOR][COLOR=#000000])[/COLOR] * .[COLOR=#000080]01[/COLOR];
gravity+=.[COLOR=#000080]006[/COLOR];
[COLOR=#0000FF]this[/COLOR].[COLOR=#000080]x[/COLOR] += [COLOR=#0000FF]Math[/COLOR].[COLOR=#0000FF]cos[/COLOR]COLOR=#000000[/COLOR] * gravity;
[COLOR=#0000FF]this[/COLOR].[COLOR=#000080]y[/COLOR] += [COLOR=#0000FF]Math[/COLOR].[COLOR=#0000FF]sin[/COLOR]COLOR=#000000[/COLOR] * gravity
[/LEFT]
now my problem is the speed of the object isn’t consistent through frame rates, does anyone know what I could do to make this possible