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

2020/3/28

Objects...

Starlord_20 Starlord_20

2020/3/28

#
I want to create multiple Text objects
Object a = new Object();
a.setImage( ... )
that's what I thought about, but it doesn't work...
danpost danpost

2020/3/28

#
Starlord_20 wrote...
I want to create multiple Text objects << Code Omitted >> that's what I thought about, but it doesn't work...
There is no setImage method available to the Object class. That method is declared in the Actor class. Therefore, the object created must be, at least, an Actor object. Next thing -- because the Actor class is abstract, you cannot use:
Actor a = new Actor();
You will need to use an extension of the Actor class. I would usually use either:
public class SimpleActor extends greenfoot.Actor {}
(which would be the entire class code) or
public class Aktor extends greenfoot.Actor {}
(which just has an easier, shorter, name).
You need to login to post a reply.