Creating Circles Along a Path

I'm looking for a similar program to this, except I need it to be a circle which repeats along a Sprite Path and forms a pattern. The path will start at the top left and finish at the bottom right with circles being created as the Sprite moves along the path.

This code could be completly wrong though. Any helpw would be appreciated.

import animax.*;

import java.awt.Rectangle;

class MovingCircle

{

public static void main(String[ ] args)

{

Stage stage = (new AnimationFrame(500, 300, 120)).getStage();

Rectangle rect = new Rectangle(0, 0, 100, 50);

stage.add(new SpritePath(100, 150, 450, 50, sprite));

stage.add(new SpritePathDisplay( ));

}

}

Message was edited by:

helloworld2007

[786 byte] By [helloworld2007a] at [2007-11-26 21:07:27]
# 1

Do you know how to use sine and cosine? Just increment the angle inside the animation loop and set the center point to each coordinate along the path. Something like this:

// In the class:

double angle = Math.PI; // start at 180 degrees

double radius = 10;

// Inside the animation loop:

Point point = path.nextPoint(); // or whatever

int x = Math.cos(angle) * radius + point.x;

int y = Math.sin(angle) * radius + point.y;

// Draw line from the point to x/y

angle += 0.2;

I think that should get you started anyway...

BinaryDigita at 2007-7-10 2:42:17 > top of Java-index,Java Essentials,Java Programming...
# 2
The code needs to be similar to the one I posted. It shouldn't involve sine and cosine.A circle sprite should repeatedly appear along a path. Anyone help?
helloworld2007a at 2007-7-10 2:42:17 > top of Java-index,Java Essentials,Java Programming...
# 3
Anyone help?
helloworld2007a at 2007-7-10 2:42:17 > top of Java-index,Java Essentials,Java Programming...