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

2014/4/2

To display random images from the right side

samarthj samarthj

2014/4/2

#
please help I am trying, to use following code and getting the error greenfootimage() has private access in greenfoot.Greenfootimage GreenfootImage img = new GreenfootImage(); WrongAnseq1 num = new GreenfootImage(img); addObject(new num(), 967, Greenfoot.getRandomNumber(515)); setImage = (img); GreenfootImage img = getImage(); if(score==0) { setImage(new GreenfootImage(""+num, 30, null, null)); }
danpost danpost

2014/4/2

#
There are multiple things wrong with this code: (1) you cannot just create a GreenfootImage object without giving one or more parameters (you cannot use 'new GreenfootImage()' with nothing inside the parenthesis); (2) you cannot set a field that holds a WrongAnseq1 object with a GreenfootImage object unless the WrongAnseq1 class is a subclass of the GreenfootImage class; (3) you cannot use both 'addObject' and 'setImage' in the same class without one of them being preceded with an object reference and a 'dot' operator (one is a World class method and the other is an Actor class method); (4) if you use 'null' for both color parameters in the GreenfootImage constructor call as in your last line of code, you will not see the image;
You need to login to post a reply.