I want to put some Sprites on path. I thought about calculate bezier path and then put sprites on calculated points. But I can't find in java method to do that.
SOLVED
This is my main method to draw line of images
private List<Sprite> drawStarLine(Point start, Point end, Point control1, Point control2, int starsCount,TextureRegion pTexture) {
ArrayList<Sprite> starsForReturn = new ArrayList<Sprite>();
ArrayList<Point> points = new ArrayList<Point>(generateBezierPath(start, end, control1, control2, starsCount));
for (int i = 0; i < points.size(); i++) {
Point p = points.get(i);
Sprite s = new Sprite((float) p.getX(), (float) p.getY(), pTexture, activity.getVertexBufferObjectManager());
s.setScale(mainScaleX / 2);
starsForReturn.add(s);
}
return starsForReturn;
}
This is how I calculate bezier path
private List<Point> generateBezierPath(Point origin, Point destination, Point control1, Point control2, int segments) {
ArrayList<Point> pointsForReturn = new ArrayList<Point>();
float t = 0;
for (int i = 0; i < segments; i++) {
Point p = new Point();
p.setX(Math.pow(1 - t, 3) * origin.x + 3.0f * Math.pow(1 - t, 2) * t * control1.x + 3.0f * (1 - t) * t * t * control2.x + t * t * t * destination.x);
p.setY(Math.pow(1 - t, 3) * origin.y + 3.0f * Math.pow(1 - t, 2) * t * control1.y + 3.0f * (1 - t) * t * t * control2.y + t * t * t * destination.y);
t += 1.0f / segments;
pointsForReturn.add(p);
}
pointsForReturn.add(destination);
return pointsForReturn;
}