1 / 8

CSS290 : Apps on Mobile Devices

CSS290 : Apps on Mobile Devices. Lecture 6: Thread Safe Event services and Coordinate System. Today: Concepts. Reading: Chapter 5 Sensors and Services Thread invoking functions Delegates Logica l Coordinate Control by Orientation vs. Hardware Coordinate from Accelerometer.

natala
Download Presentation

CSS290 : Apps on Mobile Devices

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. CSS290: Apps on Mobile Devices Lecture 6: Thread Safe Event services and Coordinate System

  2. Today: Concepts • Reading: Chapter 5 • Sensors and Services • Thread invoking functions • Delegates • Logical Coordinate Control by Orientation vs. Hardware Coordinate from Accelerometer

  3. Delegate keyword: a function pointer • Define a data type that accepts a function! • delegate returnTypeTypeName(parameter list) • E.g. delegate void MyFuncType(double a, double b) • New datatype is: MyFuncType! • Convenient for passing function pointers around!

  4. Adding a new reference into IDE • The Reference Tab in the Solution Explorer • Finding the right reference • Using the reference in your code • To work with Accelerometer we need • Microsoft.Devices.Sensors

  5. 1. AccTest: Accelerometer • Event service is called form an external thread • SHOULD NOT change our variable from that service routine • Called from external thread, danger of external thread and our own thread trying to change the same variable! • Instead: BeginInvoke()  called sometime later when it is safe. • Accelerometer X/Y/Z • Resting state for Z is -1 (gravitational pull) • Notice: -Y is downwards. • X/Y is associated with the hardware • If you change the phone orientation, X/Y direciton DOES NOT change

  6. 2. Acc Controls Obj: • Accelerometer with Orientation • Phone orientation changes the logical X/Y directions • Accelerometer returns the same X/Y/Z readings regardless of phone orientation! • We must translate the change! • Switch on Orientation changing support • Translate coordinate space depending on phone orientation

  7. 3. Bound Check • Switch off orientation (annoying) • mBall class • Passed in ContentPanel for bound checking • Random position inside the bound • Bound intersection checking • Test for X overlaps • Test for Y overlaps • Must satisfy all conditions for potential collision

  8. Exercise 6: • Integrate Bound checking with Exercise 5 • Check for ball touch net in Timer service (nice central place) • Integrate Music/Sound effect • Integrate Accelerometer for moving the net • No need for orientation support • BECAREFUL!! • mTheNet must be a Shape! (Rectangle)!! • UIImage does _NOT_ work!!

More Related