This site requires JavaScript, please enable it in your browser!
Greenfoot back
FlicknFlack
FlicknFlack wrote ...

2013/11/6

Image change problem

FlicknFlack FlicknFlack

2013/11/6

#
I got a problem with changing images, I tried like 4 diffrent codes but nothing worked. Please help me: public void act() { if (Placed == true && verstricheneZeit / 100 > rate) {aimAndShoot(); verstricheneZeit = 0; updateImg();} } public void updateImg() { if (imgCount==0) {setImage("Tower_shoot_start.png"); imgCount++;} else if (imgCount==1) {setImage("Tower_shoot_second.png"); imgCount++;} else if (imgCount==2) {setImage("Tower_shoot_third.png"); imgCount++;} else if (imgCount==3) {setImage("Tower_shoot_end.png"); imgCount=0;} }
danpost danpost

2013/11/6

#
Does 'verstricheneZeit' get a chance to each 100 times rate?
FlicknFlack FlicknFlack

2013/11/6

#
yes its : public void act() { long derzeitigeZeit = System.currentTimeMillis(); verstricheneZeit += derzeitigeZeit - letzteZeit; letzteZeit = derzeitigeZeit; } and if vertricheneZeit == 100 it crashes and there stands: Caused by: java.io.FileNotFoundException: Could not find file: Tower_shoot_start.png <-- in red at greenfoot.util.GreenfootUtil.getURL(GreenfootUtil.java:534) <-- in grey at greenfoot.GreenfootImage.loadFile(GreenfootImage.java:290) <-- in grey ... 8 more <-- in red
danpost danpost

2013/11/6

#
Oh. So, it is trying to set the images. Sounds to me like maybe the files are not in the images folder of your project. If they are there, make sure that the names of the image files are correctly represented in your code (pay attention to the case of each character, also).
FlicknFlack FlicknFlack

2013/11/6

#
before i posted this i tripple checked if the images are in the folder and if they are correctly spelled. But what i didnt checked was if there was a hidden space in the name which i cant see because the word starts in one row and ends in another, and there was one... in only one name of the images.. the first one. Im verry sorry that i wasted your time, I should get stupid mistakes like these on my own.
GreenHouse GreenHouse

2013/11/6

#
Danpost is sitting 24/7 in front of his computer, with a little monkey on his desk which is pressing continuously the browsers 'Refresh' button, for not missing any new post :) What i wanted to say; there is no waste of time ;)
danpost danpost

2013/11/6

#
No. I trained him to answer the posts for me. He does pretty good; even when I am sleeping.
You need to login to post a reply.