Course Technology iPhone 3D Game Programming All in One

I boken Course Technology iPhone 3D Game Programming All in One står det ett mycket intressant stycke om olika iphone funktioner. Det är på sidan 127-129.

iPhoneInput Class
This class has the following variables:
accelerationEvents: This read-only variable returns a list of acceleration
measurements that occurred during the previous frame.
iPhoneInput Class 127
touches: This read-only variable yields a list of objects representing the
status of all touches that occurred during the last frame.
touchCount: Another read-only variable that returns the number of
fingers touching the screen.
multiTouchEnabled: This flag variable tells us whether the system
handles multi-touch support.
accelerationEventCount: This tells us how many acceleration
measurements took place last frame.
acceleration: This read-only variable reports the last measured linear
acceleration in 3D space.
orientation: A read-only variable that reports the current device
orientation.
lastLocation: This reports the geographical location last recorded by
the device.
The class has these functions:
GetTouch: This function returns a touch object with information about
the status of a specific touch. You would use this as GetTouch( 0 ) to
get information about one finger touching the screen, or you would use
GetTouch( 0 ) through GetTouch( 4 ) to get information about all
fingers touching the screen if the touchCount is equal to 5.
GetAccelerationEvent: This function returns a specific acceleration
measurement that occurred during the previous frame.
As you can see, there’s quite a bit to cover with regard to the iPhone’s very specific
input system. Overall, the system is very good and with an innovative
thought process you can achieve great results even without hardware buttons.

 

Simpel javascript kod för iphone på att trycka på skärmen:

function OnGUI()
{
for ( i = 0; i < iPhoneInput.touchCount; i++ )
{
var tPos = iPhoneInput.GetTouch( i ).position;
var x = tPos.x;
var y = tPos.y;
GUI.Label( Rect( x, 320 – y, 300, 20 ), ‘‘Touch# ’’+ (i+ 1)+ ‘‘ Position ’’
+ tPos );
}
}

 

 

Kommentera

E-postadressen publiceras inte. Obligatoriska fält är märkta *

*

Följande HTML-taggar och attribut är tillåtna: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>