Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

onEnd does not find named method #21

Open
mrbbp opened this issue Oct 22, 2024 · 1 comment
Open

onEnd does not find named method #21

mrbbp opened this issue Oct 22, 2024 · 1 comment

Comments

@mrbbp
Copy link

mrbbp commented Oct 22, 2024

### Ani Debug -> Error @ AniCore -> setCallbackMethods(). Can't find a method of name: finAnimation

import de.looksgood.ani.*;

PVector[] liste;  // utilisation d'un tableau comme dans l'algorithme fourni
float step = 100;
boolean animationEnCours = false;
PVector[] cibles = new PVector[4];
Ani pointAni;

void setup() {
  size(800, 800);
  Ani.init(this);
  step= width/2;
  // Initialisation du tableau de points
  liste = new PVector[4];
  liste[0] = new PVector(random(width/2), random(height/2));
  liste[1] = new PVector(random(width/2) + step, random(height/2));
  liste[2] = new PVector(random(width/2) + step, random(height/2) + step);
  liste[3] = new PVector(random(width/2), random(height/2) + step);
  
  // Premier tirage de points
  nouveauxPoints();
}

void draw() {
  background(255);
  
  // Dessiner le polygone
  fill(200, 100, 100, 100);
  beginShape();
  for (PVector p : liste) {
    vertex(p.x, p.y);
  }
  endShape(CLOSE);
  
  // Dessiner les points
  fill(0);
  for (PVector p : liste) {
    ellipse(p.x, p.y, 8, 8);
  }
}

void nouveauxPoints() {
  if (!animationEnCours) {
    animationEnCours = true;
    
    // Création des nouveaux points cibles selon l'algorithme fourni
    
    cibles[0] = new PVector(random(width/2), random(height/2));
    cibles[1] = new PVector(random(width/2) + step, random(height/2));
    cibles[2] = new PVector(random(width/2) + step, random(height/2) + step);
    cibles[3] = new PVector(random(width/2), random(height/2) + step);
    
    // Animation de chaque point
    for (int i = 0; i < liste.length; i++) {
      final int index = i;
      
      // Animation X
      pointAni = Ani.to(liste[i], 2.0f, "x", cibles[i].x, Ani.ELASTIC_OUT);
      
      // Animation Y avec callback sur le dernier point
      if (i == liste.length - 1) {
        pointAni = Ani.to(liste[i], 2.0f, "y", cibles[i].y, Ani.ELASTIC_OUT, "onEnd:finAnimation");
      } else {
        pointAni = Ani.to(liste[i], 2.0f, "y", cibles[i].y, Ani.ELASTIC_OUT);
      }
    }
  }
}

void finAnimation() { // <- finAnimation is Here
  animationEnCours = false;
  for (int i = 0; i < liste.length; i++) {
    liste[i].x = cibles[i].x;
    liste[i].y = cibles[i].y;
  }
  nouveauxPoints();  // Lance automatiquement la prochaine animation
}

what i'm doing wrong?

Macos 14.7, Processing 4.3, Ani 2.7

@mrbbp mrbbp changed the title onEnd does not find function onEnd does not find named method Oct 22, 2024
@mrbbp
Copy link
Author

mrbbp commented Nov 12, 2024

hello!
anybody here?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant