Advertisement
Guest User

Untitled

a guest
Feb 13th, 2017
143
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. # create a scroll component
  2. scroll = new ScrollComponent
  3.     size: Screen.size
  4.     scrollHorizontal: false
  5.  
  6. # create a layer to put in  the scroll component
  7. myLayer = new Layer
  8.     width:  Screen.width
  9.     # make sure its tall enough to be scrollable
  10.     height: Screen.height*2
  11.     parent: scroll.content
  12.     backgroundColor: "#blue"
  13.  
  14. # listen for the onScroll event to fire and create two
  15. # temporary variables "event" and "layer"
  16. scroll.onScroll (event, layer) ->
  17.     # print the scrolling layer's y position
  18.     print layer.y
  19.     # if the y-postition of layer that's scrolling is smaller than -200
  20.     # change the background color of myLayer to red
  21.     if layer.y < -200
  22.         myLayer.backgroundColor = "red"
  23.     # otherwise set it to blue
  24.     else
  25.         myLayer.backgroundColor = "blue"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement