introduction to touchdevelop events reactive programming disclaimer: this document is provided...

11
introduction to touchdevelo events reactive 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.

Upload: lincoln-hollomon

Post on 31-Mar-2015

222 views

Category:

Documents


2 download

TRANSCRIPT

Page 1: Introduction to touchdevelop events reactive programming Disclaimer: This document is provided “as-is”. Information and views expressed in this document,

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.

Page 2: Introduction to touchdevelop events reactive programming Disclaimer: This document is provided “as-is”. Information and views expressed in this document,

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

Page 3: Introduction to touchdevelop events reactive programming Disclaimer: This document is provided “as-is”. Information and views expressed in this document,

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

Page 4: Introduction to touchdevelop events reactive programming Disclaimer: This document is provided “as-is”. Information and views expressed in this document,

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

Page 5: Introduction to touchdevelop events reactive programming Disclaimer: This document is provided “as-is”. Information and views expressed in this document,

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

Page 6: Introduction to touchdevelop events reactive programming Disclaimer: This document is provided “as-is”. Information and views expressed in this document,

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

Page 7: Introduction to touchdevelop events reactive programming Disclaimer: This document is provided “as-is”. Information and views expressed in this document,

introduction to touchdevelop

shakeo uses accelerometer to detect shake

event shake

media→songs→random→play

Page 8: Introduction to touchdevelop events reactive programming Disclaimer: This document is provided “as-is”. Information and views expressed in this document,

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

Page 9: Introduction to touchdevelop events reactive programming Disclaimer: This document is provided “as-is”. Information and views expressed in this document,

introduction to touchdevelop

camera buttonso pressed, half-pressed, released

events triggered by phone camera button

Page 10: Introduction to touchdevelop events reactive programming Disclaimer: This document is provided “as-is”. Information and views expressed in this document,

introduction to touchdevelop

tap on …o tap event on wall elementso one event per element kind

Page 11: Introduction to touchdevelop events reactive programming Disclaimer: This document is provided “as-is”. Information and views expressed in this document,

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