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

2012/7/16

how do i make a new object?!

freed freed

2012/7/16

#
havin trouble makin new object in my world pls help : )
freed freed

2012/7/16

#
i meant how do i cause one object to make another
SPower SPower

2012/7/16

#
Let's say you want to create an object from the class MyClass, do this:
1
MyClass newObject = new MyClass();
After this, you can use the newObject for whatever you want.
danpost danpost

2012/7/16

#
I think what you want is:
1
getWorld().addObject(new MyClass(), x, y);
This will create a new 'MyClass' object and add it to the world at (x, y) from any Actor class object that is in the world.
Upupzealot Upupzealot

2012/7/16

#
afterall the "MyClass" above should be a subclass of Actor~
SPower SPower

2012/7/17

#
@freed I see you're a beginner, you might want to go through this course: http://www.greenfoot.org/scenarios/4949 download the PDF in the description, And later on, take a look at some other courses: http://www.greenfoot.org/collections/321
freed freed

2012/7/18

#
thanks guys ur super!
You need to login to post a reply.