I have a project where I need
- Create a sticker.
- Clicking on it, stick the sound.
- Repeat the next click and place the sticker. (You need to be able to post as many times as I want without returning and clicking on the original sticker again.)
- Be able to click on another sticker and choose it for placement.
In my code, I have all the variable stickers starting as false. After the correct conditions are met, 1 sticker variable will be displayed, and I can place the sticker. But when I click on the second sticker, the first sticker is still correct and puts the sticker on the second sticker. I do not want it. How to change the sticker variable to false when I release the left mouse button on the second sticker. My code changes it to false after. I want earlier. Please help. Thanks.
boolean hatSoundPlay = false;
boolean bluntSoundPlay = false;
boolean dealwithitSoundPlay = false;
boolean weedSoundPlay = false;
while(true) {
int clickX = EZInteraction.getXMouse();
int clickY = EZInteraction.getYMouse();
if (EZInteraction.wasMouseLeftButtonReleased()){
if (hatPicture.isPointInElement(clickX, clickY)){
bluntSoundPlay = false;
weedSoundPlay = false;
dealwithitSoundPlay = false;
if (!hatSoundPlay) {
hatsound.play();
hatSoundPlay = true;
}
}
else if (backgroundPicture.isPointInElement(clickX, clickY) && hatSoundPlay == true && EZInteraction.wasMouseLeftButtonReleased()){
EZ.addImage("hat.png", clickX, clickY);
hatsound.play();
}
if (bluntPicture.isPointInElement(clickX, clickY)){
hatSoundPlay = false;
weedSoundPlay = false;
dealwithitSoundPlay = false;
if (!bluntSoundPlay) {
bluntsound.play();
bluntSoundPlay = true;
}
}
else if (backgroundPicture.isPointInElement(clickX, clickY) && bluntSoundPlay == true && EZInteraction.wasMouseLeftButtonReleased()){
EZ.addImage("blunt.png", clickX, clickY);
bluntsound.play();
}
if (dealwithitPicture.isPointInElement(clickX, clickY)){ hatSoundPlay = false;
bluntSoundPlay = false;
weedSoundPlay = false;
if (!dealwithitSoundPlay) {
dealwithitsound.play();
dealwithitSoundPlay = true;
}
}
else if (backgroundPicture.isPointInElement(clickX, clickY) && dealwithitSoundPlay == true && EZInteraction.wasMouseLeftButtonReleased()){
EZ.addImage("dealwithit.png", clickX, clickY);
dealwithitsound.play();
}
if (weedPicture.isPointInElement(clickX, clickY)){
dealwithitSoundPlay = false;
hatSoundPlay = false;
bluntSoundPlay = false;
if (!weedSoundPlay) {
weedsound.play();
weedSoundPlay = true;
}
}
else if (backgroundPicture.isPointInElement(clickX, clickY) && weedSoundPlay == true && EZInteraction.wasMouseLeftButtonReleased()){
EZ.addImage("weed.png", clickX, clickY);
weedsound.play();
}
}
EZ.refreshScreen();
}
source
share