cannot create GLMovie object within class

edited November 2016 in Raspberry PI

hi all, i get an error when creating a GLMovie object within a class like:

class Film {

  GLMovie vid;
  String filename;

  Film(String tempFilename) {    
    filename = tempFilename;

    vid = new GLMovie(this,filename); //error: 
    //The constructor "GLMovie(Film,String)" does not exist
    vid.loop();
  }
}

also the use of "this" is not clear to me ...

thanks:) ps: the formatting looks a bit strange here!? sorry for that

Tagged:

Answers

  • Answer ✓

    (highlight code, press ctrl-o. i've done that for you)

    this is probably meant to be PApplet. but if you move the call into a class then this becomes the class, which is probably why it isn't working.

    you need to pass the PApplet into you class, as another argument in your Film constructor.

  • edited November 2016

    All loading resources should go to setup(). Then you can pass the already loaded resource to your classes' constructor:

    // forum.Processing.org/two/discussion/19174/
    // cannot-create-glmovie-object-within-class#Item_2
    
    // 2016-Nov-20
    
    import gohai.glvideo.GLMovie;
    Film film;
    
    static final String MOVIE_FILE = "transit.mov";
    
    void settings() {
      film = new Film(new GLMovie(this, MOVIE_FILE), 0, 0);
      while (film.vid.height == 0)  delay(5);
      size(film.vid.width, film.vid.height);
    }
    
    void draw() {
      film.display();
    }
    
    class Film {
      final GLMovie vid;
      final int x, y;
    
      Film(GLMovie mov, int xx, int yy) {
        (vid = mov).loop();
        x = xx;
        y = yy;
      }
    
      void display() {
        set(x, y, vid);
      }
    }
    
  • edited November 2016

    thanks koogs for the PApplet hint. (also for the edit). i found this on the topic: https://forum.processing.org/one/topic/reference-papplet-of-sketch.html

    thanks GoToLoop too.

Sign In or Register to comment.