introduction to touchdevelop events reactive programming disclaimer: this document is provided...
TRANSCRIPT
introduction to touchdevelop
eventsreactive programming
Disclaimer: This document is provided “as-is”. Information and views expressed in this document, including URL and other Internet Web site references, may change without notice. You bear the risk of using it. This document does not provide you with any legal rights to any intellectual property in any Microsoft product. You may copy and use this document for your internal, reference purposes. © 2012 Microsoft Corporation. All rights reserved. Microsoft, Windows, and Windows Live are trademarks of the Microsoft group of companies. All other trademarks are property of their respective owners.
introduction to touchdevelop
events around youo tap on the shoulder
• turn head, say “hello”, shake hand
o traffic light goes red• hit the brakes
o hear cool song• dance, sing
►find 3 more events and reactions around you
introduction to touchdevelop
events in phoneo special action triggered by sensors or
media player state• shaking, orientation change
• active song changed, player paused, resumed
o reacts by running the event code,• i.e. executes the actions associated to
the event
introduction to touchdevelop
execution modelo events run to completion before another
event starts running• events (and actions) never interleave
o scripts with events automatically enter an event loop (“gameloop”) when an action started by the user ends
o to stop the event loop, use time→stop• user can stop script as well
✿ http://touchdevelop.com/help/events
introduction to touchdevelop
gameloopo event that triggers every 50mso update the state of a game
board : Board // a global board variableevent gameloop
…
board →evolve board →update on wall
introduction to touchdevelop
orientationo respond to orientation changeso phone face up/down, landscape
left/right
event phone face up
player→resume
event phone face down
player→pause
introduction to touchdevelop
shakeo uses accelerometer to detect shake
event shake
media→songs→random→play
introduction to touchdevelop
player eventso active song changed notifies that a
new song is playingo player state changed notifies that
the player has started to play, or paused, or resumed, etc…
event active song changed
player→active song→post to wall
introduction to touchdevelop
camera buttonso pressed, half-pressed, released
events triggered by phone camera button
introduction to touchdevelop
tap on …o tap event on wall elementso one event per element kind
introduction to touchdevelop
empty space on wallo event that triggers when new space
appears on the wallo typically happens when the user
reaches the end of the wall content and allows to fill the wall with more data