Skip to content

Instantly share code, notes, and snippets.

@gavinmcfarland
Last active August 29, 2015 14:03
Show Gist options
  • Save gavinmcfarland/f2b2c8c5928fc66dcf39 to your computer and use it in GitHub Desktop.
Save gavinmcfarland/f2b2c8c5928fc66dcf39 to your computer and use it in GitHub Desktop.
Example of changing state layer based on the current state of another layer
# Create layer 1
layer1 = new Layer
x: 200
y: 200
width: 100
height: 100
# Add your required states
layer1.states.add
second: {y:100, scale:0.6, rotationZ:100}
third: {y:300, scale:1.3, blur:4}
fourth: {y:200, scale:0.9, blur:2, rotationZ:200}
# Create the second layer
layer2 = new Layer
width: 200
height: 200
# Add its required states
layer2.states.add
second: {y:100, scale:0.6, rotationZ:100}
third: {y:300, scale:1.3, blur:4}
fourth: {y:200, scale:0.9, blur:2, rotationZ:200}
# Now when layer1 is clicked...
layer1.on Events.Click, ->
# Show the next state
layer1.states.next()
# When the state matches "third"
if layer1.states.current == "third"
# Change the state of layer2 to "second"
layer2.states.switch "second"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment