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

2017/10/29

I do not know why the MyWorld cannot find symbol - class Pinnball here is a copy of what the code under MyWorld is showing.

DavidButts DavidButts

2017/10/29

#
import greenfoot.*; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo) /** * Write a description of class MyWorld here. * * @author (your name) * @version (a version number or a date) */ public class MyWorld extends World { /** * Constructor for objects of class MyWorld. * */ public MyWorld() { // Create a new world with 600x400 cells with a cell size of 1x1 pixels. super(700, 700, 1); prepare(); } /** * Prepare the world for the start of the program. * That is: create the initial objects and add them to the world. */ private void prepare() { Teddy teddy = new Teddy(); addObject(teddy,201,288); Teddy teddy2 = new Teddy(); addObject(teddy2,559,183); Teddy teddy3 = new Teddy(); addObject(teddy3,587,500); Teddy teddy4 = new Teddy(); addObject(teddy4,170,596); Pinball pinball = new Pinball(); addObject(pinball,373,354); } }
danpost danpost

2017/10/29

#
And what does the Pinball class look like?
DavidButts DavidButts

2017/10/29

#
import greenfoot.*; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo) /** * Write a description of class Pinnball here. * * @author (your name) * @version (a version number or a date) */ public class Pinnball extends Actor { /** * Act - do whatever the Pinnball wants to do. This method is called whenever * the 'Act' or 'Run' button gets pressed in the environment. */ public void act () { killTeddy(); int a; int b; int c; int d; moveUp(a = 3); moveDown(b = -3 ); turnRight(c = 2 ); turnLeft(d = -2); } public int moveUp( int a ) { if(Greenfoot.isKeyDown("up")) { move(a); } return (a); } public int moveDown(int b ) { if(Greenfoot.isKeyDown("down")) { move(b); } return (b); } public int turnRight(int c ) { if(Greenfoot.isKeyDown("right")) { turn(c); } return(c); } public int turnLeft( int d ) { if (Greenfoot.isKeyDown("left")) { turn(d); } return(d); } private void killTeddy() { if (isTouching(Teddy.class)) { removeTouching(Teddy.class); } } }
DavidButts DavidButts

2017/10/29

#
Thank you, I just now caught the misspelling after I posted the code.
You need to login to post a reply.