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

2014/6/19

stuck again

FootLongTurkey FootLongTurkey

2014/6/19

#
I was given an amazing amount of info before, yet I still cant get the program to work :(
 public void act()
    {
        if (Greenfoot.mouseClicked(null)) {    
            List all = getObjects(MyActor.class);    
            MyActor a = (MyActor) all.get(Greenfoot.getRandomNumber(all.size()));    
            a.getImage().setTransparency(255);    
        }  
    }
FootLongTurkey FootLongTurkey

2014/6/19

#
list all doesn't exist apparently?
11frendash 11frendash

2014/6/19

#
is that all the programming????????????
danpost danpost

2014/6/19

#
Please supply the error message you are getting (copy/paste into your post). I have a feeling (though I cannot be sure) that it may be that there are no 'MyActor' objects in the world and you are getting an IllegalArgumentException' error when trying to 'get' a non-existant element from the existing list. BTW, the list will ALWAYS exist; it just might be empty of elements.
You need to login to post a reply.