PDA

View Full Version : lightbulb on/off


essjai
11-16-2011, 09:48 AM
"Create a world with a lightbulb (Lights) and a method turnOnOff that turns the lightbulb on/off depending on whether it is already on/off. When the lightbulb is on, its emissive color property has a value of yellow. When the lightbulb is off, it's emissive color is black. Write a Boolean function isLightOn that returns true if the light bulb is on and false if it is off. When clicked, the lightbulb should turn on/off."

Okay I know this probably sounds like a stupid question because it's such an easy task but I'm completely stuck.

I made a new event for when the mouse clicks the lightbulb.
I also created a new method turnOnOff and I made the Boolean function isLightOn. It works fine.
But I don't know what to do now. Am I supposed to put the function into the method I made, if so how do i do this? If not, what am I supposed to do?

dakota95
11-17-2011, 01:25 PM
I'm not sure if I understand correctly interim what it sounds like, just create an if/else. Say if lightbulb is on turn off. Else turn on. Then drag it into the "if mouse is clicked on"

GameKid
11-17-2011, 02:48 PM
Make two methods and use your boolean in the event.