Loading...
Processing Forum
Recent Topics
All Forums
Screen name:
capri1566
capri1566's Profile
1
Posts
0
Responses
0
Followers
Activity Trend
Last 30 days
Last 30 days
Date Interval
From Date :
To Date :
Go
Loading Chart...
Posts
Responses
PM
Show:
All
Discussions
Questions
Expanded view
List view
Private Message
Need help with mousePressed
[1 Reply]
04-Jan-2013 07:44 AM
Forum:
Programming Questions
Hi,
I´m working on a programm/game the first time in my life and I need help with one function.
I have no idea how to change this:
float xleft=100, yleft=50, rwidth=77, rheight = 77;
PImage depp;
PImage karteverdeckt;
PImage hintergrund;
PImage k1;
boolean clickedCard;
void setup() {
size(800, 500);
depp=loadImage("depp.jpg");
karteverdeckt=loadImage ("karteverdeckt.jpg");
hintergrund=loadImage ("hintergrund.jpg");
k1=loadImage ("k1.jpg");
}
void draw(){
background(hintergrund);
if (clickedCard) {
image(depp, 100, 50, 77,77);
}
else {
image (karteverdeckt, 100,50,77,77);
}
if (clickedCard) {
image(k1, 100, 150, 77,77);
}
else {
image (karteverdeckt, 100,150,77,77);
}
}
void mousePressed() {
if (mouseX > xleft && mouseX < xleft + rwidth && mouseY > yleft && mouseY < yleft + rheight) {
clickedCard=true;
}
else { //ausserhalb geklickt
clickedCard=false;
}
}
so that when I click on one card this one will change and not both. Now I have the problem, that when I press on one card both are changing. How can I change this? Can anybody help me please?
Thanks a lot!
«Prev
Next »
Moderate user : capri1566
Forum