We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
IndexProgramming Questions & HelpSyntax Questions › Issues with mousePressed
Page Index Toggle Pages: 1
Issues with mousePressed (Read 230 times)
Issues with mousePressed
Oct 9th, 2008, 11:34pm
 
I am in a class which is teaching Programming, and my professor and I are both stumped. I am trying to set a mousePressed function so that when the mouse is pressed the cursor turns into an image which I have loaded. Here is the code as written. You will have to include your own images if you want to try this. Thanks!

PImage b;
PImage b2;

void setup() {
background(10);
 size(700,600);
b = loadImage("071108-cvr-bernanke-grid1col-8a.hmedium.jpg");
 b2 = loadImage("OOPS.gif");
image(b, 123, 150);
}

void draw() {
if(mousePressed){
  cursor(b2, mouseX, mouseY);
} else {
  noCursor();
}
}


Re: Issues with mousePressed
Reply #1 - Oct 10th, 2008, 12:01am
 
the 2nd and 3rd parameters to cursor aren't what you're thinking they are... they're where about on the cursor image the "point" is, i.e. the bit that actually clicks.

e.g. on an arrow shaped cursor, the point is the top left.. on a + shaped one, the active spot would be the middle. So try cursor(b2,0,0);
Page Index Toggle Pages: 1