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

2014/2/23

NEED HELP!

callume8 callume8

2014/2/23

#
Hey I'm trying to import a walk sequence of photos to make animation. when I compile I get no syntax errors but it says it cant find the pictures. I did not change the default destination and i dont know what to do? thanks
Zamoht Zamoht

2014/2/23

#
Some code would be great to look at.
callume8 callume8

2014/2/23

#
sure this is it import greenfoot.*; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo) /** * Write a description of class Player here. * * @author (your name) * @version (a version number or a date) */ public class Player extends Actor { private int vSpeed = 0; private int acceleration =2; private boolean jumping; private int jumpStrength =20; private int speed = 4; private GreenfootImage run10r = new GreenfootImage("run10r.png"); private GreenfootImage run20r = new GreenfootImage("run20r.png"); private int frame = 1; /** * Act - do whatever the Player wants to do. This method is called whenever * the 'Act' or 'Run' button gets pressed in the environment. */ public void act() { checkFall(); checkKey(); } public void checkKey() { if(Greenfoot.isKeyDown("space") && jumping == false) { jump(); } if(Greenfoot.isKeyDown("z")) { moveRight(); } if(Greenfoot.isKeyDown("left")) { moveLeft(); } } public void moveLeft() { setLocation(getX()-speed, getY()); } public void moveRight() { setLocation(getX()+speed, getY()); animateRight(); } public void animateRight() { if (frame == 1) { setImage(Player); frame =2; } else if (frame == 2) { setImage(Player); frame = 1; } frame ++; } public void fall() { setLocation(getX(), getY() +vSpeed); if(vSpeed<=9) { vSpeed = vSpeed + acceleration; } jumping = true; } public boolean onGround() { int spriteHeight = getImage().getHeight(); int LookForGround = (int)(spriteHeight/2) + 5; Actor ground = getOneObjectAtOffset (0, LookForGround, Platform.class); if(ground == null) { jumping = true; return false; } else { moveToGround(ground); return true; } } public void moveToGround(Actor ground) { int groundHeight = ground.getImage().getHeight(); int newY = ground.getY() - (groundHeight + getImage().getHeight())/2; setLocation(getX(), newY); jumping = false; } public void checkFall() { if (onGround()) { vSpeed =0; } else { fall(); } } public void jump() { vSpeed = vSpeed -jumpStrength; jumping = true; fall(); } }
callume8 callume8

2014/2/23

#
this is the same problem http://www.greenfoot.org/topics/3009
callume8 callume8

2014/2/23

#
this is what the terminal window says java.lang.IllegalArgumentException: java.io.FileNotFoundException: Could not find file: run10r.jar at greenfoot.GreenfootImage.loadFile(GreenfootImage.java:293) at greenfoot.GreenfootImage.<init>(GreenfootImage.java:109) at Player.<init>(Player.java:17) at background.prepare(background.java:36) at background.<init>(background.java:21) at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57) at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) at java.lang.reflect.Constructor.newInstance(Constructor.java:525) at greenfoot.core.Simulation.newInstance(Simulation.java:581) at greenfoot.platforms.ide.WorldHandlerDelegateIDE$3.run(WorldHandlerDelegateIDE.java:409) at greenfoot.core.Simulation.runQueuedTasks(Simulation.java:468) at greenfoot.core.Simulation.maybePause(Simulation.java:281) at greenfoot.core.Simulation.runContent(Simulation.java:212) at greenfoot.core.Simulation.run(Simulation.java:205) Caused by: java.io.FileNotFoundException: Could not find file: run10r.jar at greenfoot.util.GreenfootUtil.getURL(GreenfootUtil.java:537) at greenfoot.GreenfootImage.loadFile(GreenfootImage.java:290) ... 14 more java.lang.IllegalArgumentException: java.io.FileNotFoundException: Could not find file: run10r.png at greenfoot.GreenfootImage.loadFile(GreenfootImage.java:293) at greenfoot.GreenfootImage.<init>(GreenfootImage.java:109) at Player.<init>(Player.java:17) at background.prepare(background.java:36) at background.<init>(background.java:21) at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57) at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) at java.lang.reflect.Constructor.newInstance(Constructor.java:525) at greenfoot.core.Simulation.newInstance(Simulation.java:581) at greenfoot.platforms.ide.WorldHandlerDelegateIDE$3.run(WorldHandlerDelegateIDE.java:409) at greenfoot.core.Simulation.runQueuedTasks(Simulation.java:468) at greenfoot.core.Simulation.maybePause(Simulation.java:281) at greenfoot.core.Simulation.runContent(Simulation.java:212) at greenfoot.core.Simulation.run(Simulation.java:205) Caused by: java.io.FileNotFoundException: Could not find file: run10r.png at greenfoot.util.GreenfootUtil.getURL(GreenfootUtil.java:537) at greenfoot.GreenfootImage.loadFile(GreenfootImage.java:290) ... 14 more
Zamoht Zamoht

2014/2/23

#
If you right click on a class and choose "Set image..." it'll open up a window as you probably know. Under "Scenario images:" you should be able to find "run10r.png", if not you should import the image using the button "Import from file...". Please tell me about the results.
You need to login to post a reply.