Mouse events..

General discussion about the Processing Layers library.

Mouse events..

Postby sameer27 » Sat Feb 27, 2010 12:28 am

Hi,

I am developing my code in Eclipse and tried to run the laser burn example... but I am getting errors in files that extend 'Layer'.. For example:

=============================== Code begins ==========================================
package testPackage;

import java.util.Iterator;
import java.util.SortedSet;
import java.util.TreeSet;

import traer.physics.*;
import processing.core.*;
import com.nootropic.processing.layers.*;

public class HeatLayer extends Layer {

  SortedSet hotSpots = new TreeSet();
  int hot = color(255, 40, 40);
  int cold = color(0);
  int size;
  int maxAge = 40;
  boolean newClick = false;

  public HeatLayer(PApplet parent) {
    super(parent);
  }

  public void mousePressed() {
    newClick = true;
  }

  public void draw() {
    if (mousePressed) {
      hotSpots.add(new HotSpot(mouseX, mouseY, newClick));
// Eclipse gives an error on the symbols mouseX, mouseY and mousePressed.. says it can't resolve them.. same problem for symbols like
// 'key' and color()...
      newClick = false;
    }
    //More code...

  }

}

=============================== Code ends ==========================================

Anything I am missing here??

--Sameer
sameer27
Newbie
Newbie
 
Posts: 1
Joined: Sat Feb 27, 2010 12:21 am

Re: Mouse events..

Postby Michael » Mon Mar 01, 2010 1:16 pm

The problem is that your HeatLayer class needs to be an inner class of the PApplet class.  That is, HeatLayer needs to be a class defined within the LaserBurn class.  If it is a separate class, it does not have access to member fields of the PApplet.  This is true whenever you are using Eclipse to define other classes.  That is, it is a Processing thing, not a Processing Layers constraint.  They need to be inner classes.  Make sense?
Michael
Administrator
Administrator
 
Posts: 477
Joined: Sat May 29, 2010 8:24 am


Return to General Discussion

Who is online

Users browsing this forum: No registered users and 1 guest