Closed aswinmohanme closed 6 years ago
Use HTween instead....something like this:
import hype.*;
import hype.extended.layout.*;
import hype.extended.colorist.*;
import hype.extended.behavior.*;
HDrawablePool pool;
PVector[] finalLoc;
PFont fnt;
HText txt;
HDrawable[] drawablePool = new HDrawable[800];
HTween tween;
HTimer timer;
void setup() {
size(800, 600);
H.init(this);
fnt = createFont("Roboto",64);
txt = new HText("ISQUIP", 200, fnt);
H.add(txt)
.anchorAt(H.CENTER)
.locAt(H.CENTER)
.noStroke()
.noFill()
;
HShapeLayout lay = new HShapeLayout().target(txt);
finalLoc = new PVector[800];
for(int i=0; i < 800; ++i){
finalLoc[i] = lay.getNextPoint();
}
pool = new HDrawablePool(800);
pool.autoAddToStage()
.add(
new HEllipse()
)
.layout(new HShapeLayout().target(new HRect().size(width, height)))
.colorist(new HColorPool(#e74c3c, #f1c40f, #2980b9, #27ae60, #16a085, #8e44ad).fillOnly())
.onCreate(
new HCallback() {
public void run(Object obj) {
HEllipse e = (HEllipse) obj;
e.size(random(2,10))
.noStroke()
;
}
}
)
;
for(int i=0; i < 800; ++i){
drawablePool[i] = pool.request();
tween = new HTween()
.target(drawablePool[i]).property(H.LOCATION)
.start( drawablePool[i].x(), drawablePool[i].y() )
.end( finalLoc[i].x, finalLoc[i].y )
.ease(0.1)
.spring(0.2)
;
}
}
void draw() {
H.drawStage();
}
Thanks, works perfectly
Problem: I have the following code to render a text of Bubbles on to the screen. The bubbles should move from a random location on the screen to their respective positions.
Here is the Code
The problem is that the particles are not slowing down after reaching their positions, and they accelarate out of the screen.
How do I fix this ?