Question: How to create custom properties in extended classes?
Hey everyone! I'm want to make a class for my nav buttons. And I'd like to create each button like this:
nav_a = new NavButton
This is what my class looks like:
# NAV button class
class NavButton extends Layer
constructor: (options) ->
# Get default layer functionality
super _.defaults options,
# Set default properties
@myState = false
@on_image = "images/nav_a_on.png"
@off_image = "images/nav_a_off.png"
# Deactivate by default
# Add events handlers
@myState = [email protected]
@image = @on_image
@image = @off_image
# END NAV class
How do I write the class so that it accepts on_image and off_image as input properties when a button is created? I have been Googling for hours ;) Any input deeply appreciated! Thanks.