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

2016/10/27

Method not being found from an Actor

SavioKing SavioKing

2016/10/27

#
Hey guys, i've been trying to implement a traffic system for a school project. I've been trying to call a method form the TrafficLight class that informs if the lights are red or green, but I can't seem to do it right. Here is the method in class TrafficLight:
danpost danpost

2016/10/28

#
The method is in the TrafficLight class, not the Actor class. Therefore, the field holding the TrafficLight object needs to hold a TrafficLight object, not just any Actor object:
TrafficLight traffic = (TrafficLight)getOneObjectAtOffset(0, 0, TrafficLight.class);
You need to login to post a reply.