Java-Gaming.org Hi !
 Featured games (88) games approved by the League of Dukes Games in Showcase (681) Games in Android Showcase (196) games submitted by our members Games in WIP (746) games currently in development
 News: Read the Java Gaming Resources, or peek at the official Java tutorials
Pages: [1]
 ignore  |  Print
 Need a Equation to fix My animation problem :/  (Read 1006 times) 0 Members and 1 Guest are viewing this topic.
supaFool

Junior Devvie

Projects: 2

 « Posted 2013-01-06 22:17:36 »

1st Post!

Problem is the farther the xx is from player.layoutXProperty()...etc the faster the player moves, cause he is set to go from point A to point B in 1500ms....any ideas?

Thanks!

@Override
public void handle(MouseEvent m) {
double xx = m.getSceneX();
double yy = m.getSceneY();

Timeline t = new Timeline();
KeyValue kvX = new KeyValue(player.layoutXProperty(), xx);
KeyValue kvY = new KeyValue(player.layoutYProperty(), yy);
KeyFrame kfX = new KeyFrame(Duration.millis(1500), kvX);
KeyFrame kfY = new KeyFrame(Duration.millis(1500), kvY);
t.play();

HeroesGraveDev

JGO Kernel

Medals: 376
Projects: 11
Exp: 3 years

┬─┬ノ(ಠ_ಠノ)(╯°□°)╯︵ ┻━┻

 « Reply #1 - Posted 2013-01-06 22:27:29 »

Either:

• Calculate the angle, then move the player by using sin() and cos()
• Put a cap on the movement

supaFool

Junior Devvie

Projects: 2

 « Reply #2 - Posted 2013-01-07 17:06:51 »

Fixed it, had to divide the total distance it is going to move by 10, and make it a "x" amount of time to get to each segment, that kept it at a steady speed. Just in case anyone was wondering
Pages: [1]
 ignore  |  Print

You cannot reply to this message, because it is very, very old.

 GrandCastle (14 views) 2016-07-01 09:13:47 GrandCastle (15 views) 2016-07-01 09:09:45 CopyableCougar4 (74 views) 2016-06-25 16:56:52 Hydroque (105 views) 2016-06-22 02:17:53 SwampChicken (108 views) 2016-06-20 13:22:57 SwampChicken (110 views) 2016-06-20 13:22:49 SwampChicken (104 views) 2016-06-20 13:22:26 Hydroque (148 views) 2016-06-15 08:22:50 Hydroque (144 views) 2016-06-13 06:40:55 DarkCart (251 views) 2016-05-29 02:30:33
 Spasi 49x theagentd 40x NegativeZero 38x KaiHH 33x LiquidNitrogen 23x princec 22x DavidBVal 19x Opiop 16x ra4king 13x TritonDreyja 11x CoDi^R 10x ags1 10x Archive 10x purenickery 9x delt0r 7x Roquen 7x
 Making a Dynamic Plugin Systemby Hydroque2016-06-25 00:13:25Java Data structures2016-06-13 21:22:09Java Data structures2016-06-13 21:20:42FPS Camera Tutorialby Hydroque2016-05-22 05:40:58Website offering 3D Models specifically for games for freeby vusman2016-05-18 17:23:09Website offering 3D Models specifically for games for freeby vusman2016-05-09 08:50:56Website offering 3D Models specifically for games for freeby vusman2016-05-06 11:10:21Website offering 3D Models specifically for games for freeby vusman2016-04-29 12:56:17
 java-gaming.org is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑gaming.org