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

2016/9/3

Add an Object in the World ?

BrySch BrySch

2016/9/3

#
Hi! I started to work with Greenfoot for 2 days and I want to learn how I have to add an Actor (after to have created it) in the World. Here is my Source Code:
import greenfoot.*;  // (World, Actor, GreenfootImage, Greenfoot and MouseInfo)



I hope that somebody can help me, thank you already!

Bryan


public class Space extends World
{

    
    public Space()
    {    
       super(600, 400, 1);
       addObject(Rocket, 200, 200);
    }
}
Super_Hippo Super_Hippo

2016/9/3

#
If you have an Actor subclass named 'Rocket', the line should read:
addObject(new Rocket(), 200, 200);
You need to login to post a reply.