SlideShare ist ein Scribd-Unternehmen logo
1 von 15
Downloaden Sie, um offline zu lesen
Openframeworks
         x iPad Game Design (3)




黃怡靜
Janet Huang
2012.05.15
Today’s Topic
    - Addons in OF

    - Three examples
      - Show unicode fonts
      - Play sounds
      - Touch polygon
http://ofxaddons.com/
How to use addons into OF?
  Step 1: Create a basic OF application
  Step 2: Create a folder named “addons” inside project folder
           and put addons “ofxTrueTypeFontUC” into it
  Step 3: Open your project.xcodeproj and add files in addons
           and only keep src folder
  Step 4: Include the header file in testApp.h
step 2


         step 1




                  step 4




step 3




                  start coding!
Show unicode fonts
   - you can’t display Japanese, Chinese...etc directly
   - you should use addons “ofxTrueTypeFontUC”




Fonts
   - font type
      - TrueType fonts (*.ttf)
      - OpenType fonts (*.oft)
   - put them into “project/bin/data/”
Show unicode fonts
          #pragma once

          #include     "ofMain.h"
          #include     "ofxiPhone.h"
          #include     "ofxiPhoneExtras.h"
          #include     "ofxTrueTypeFontUC.h"

          class testApp : public ofxiPhoneApp {
          !
          public:
          ! void setup();
          ! void update();
          ! void draw();
          ! void exit();
          !
          ! void touchDown(ofTouchEventArgs &touch);
          ! void touchMoved(ofTouchEventArgs &touch);
          ! void touchUp(ofTouchEventArgs &touch);
          ! void touchDoubleTap(ofTouchEventArgs &touch);
          ! void touchCancelled(ofTouchEventArgs &touch);

          !    void   lostFocus();
          !    void   gotFocus();
          !    void   gotMemoryWarning();
          !    void   deviceOrientationChanged(int newOrientation);

                ofxTrueTypeFontUC myFont;
                ofxTrueTypeFontUC myFont2;
          };
                                                                      testApp.h
Show unicode fonts
          #include "testApp.h"


          void testApp::setup(){!
          ! // register touch events
          ! ofRegisterTouchEvents(this);
          !
          ! // initialize the accelerometer
          ! ofxAccelerometer.setup();
          !
          ! //iPhoneAlerts will be sent to this.
          ! ofxiPhoneAlerts.addListener(this);
          !
          ! //If you want a landscape oreintation
          ! iPhoneSetOrientation(OFXIPHONE_ORIENTATION_LANDSCAPE_RIGHT);
          !
              ofBackground(0,0,0);
              myFont.loadFont("MSPGothic.ttf", 28);
              myFont2.loadFont("Sudbury_Basin_3D.ttf", 28);
          }

          void testApp::draw(){
              ofSetColor(255, 0, 0);
              myFont.drawString("哈囉!!", 50, 100);
              ofSetHexColor(0xffffff);
              myFont2.drawString("HELLO!!", 50, 200);
          }


                                                                  testApp.mm
Play sounds
   - sound type
     - .wav, .aif, .mp3, .mp2, .ogg or .raw format.
     - .caf (Core Audio Format)

       afconvert -f caff -d LEI16@44100 -c 1 sound.wav sound.caf
       afconvert -f caff -d LEI16@22050 -c 1 sound.wav sound.caf
                                      sample rate


   - put them into “project/bin/data/”
Play sounds
              #pragma once

              #include "ofMain.h"
              #include "ofxiPhone.h"
              #include "ofxiPhoneExtras.h"

              class testApp : public ofxiPhoneApp {
              !
              public:
              !   void setup();
              !   void update();
              !   void draw();
              !   void exit();
              !
              !   void touchDown(ofTouchEventArgs &touch);
              !   void touchMoved(ofTouchEventArgs &touch);
              !   void touchUp(ofTouchEventArgs &touch);
              !   void touchDoubleTap(ofTouchEventArgs &touch);
              !   void touchCancelled(ofTouchEventArgs &touch);

              !    void   lostFocus();
              !    void   gotFocus();
              !    void   gotMemoryWarning();
                   void   deviceOrientationChanged(int newOrientation);

                   ofSoundPlayer mySound;
              };




                                                                          testApp.h
Play sounds

       #include "testApp.h"


       void testApp::setup(){!
       !   // register touch events
       !   ofRegisterTouchEvents(this);
       !
       !   // initialize the accelerometer
           ofxAccelerometer.setup();
       !
         ! //iPhoneAlerts will be sent to this.
         ! ofxiPhoneAlerts.addListener(this);
       !
       !   //If you want a landscape oreintation
       !   //iPhoneSetOrientation(OFXIPHONE_ORIENTATION_LANDSCAPE_RIGHT);
       !
       !   ofBackground(0, 0, 0);

           mySound.loadSound("cat.wav");
           mySound.setVolume(0.75f);
           mySound.setMultiPlay(true);
       }

       void testApp::touchDown(ofTouchEventArgs &touch){
           mySound.play();
       }


                                                                   testApp.mm
Touch polygon

   ofInsidePoly()
   ofInsidePoly(...)
   bool	
  ofInsidePoly(float	
  x,	
  float	
  y,	
  const	
  vector<	
  ofPoint	
  >	
  &poly)



                                          1 (x,y)
                              13       14     2 3
                                12                        4
                            11                                 5
                                    10                6
                                              8
                                       9              7
Touch polygon
           #pragma once

           #include "ofMain.h"
           #include "ofxiPhone.h"
           #include "ofxiPhoneExtras.h"

           class testApp : public ofxiPhoneApp {
           !
           public:
               void setup();
           !   void update();
           !   void draw();
           !   void exit();
           !
           !   void touchDown(ofTouchEventArgs &touch);
           !   void touchMoved(ofTouchEventArgs &touch);
           !   void touchUp(ofTouchEventArgs &touch);
           !   void touchDoubleTap(ofTouchEventArgs &touch);
           !   void touchCancelled(ofTouchEventArgs &touch);

           !    void   lostFocus();
           !    void   gotFocus();
           !    void   gotMemoryWarning();
           !    void   deviceOrientationChanged(int newOrientation);

                ofPolyline line;
           };


                                                                       testApp.h
#include "testApp.h"
                                                          Touch polygon
void testApp::setup(){!
  ! ofRegisterTouchEvents(this);
  ! ofxAccelerometer.setup();
!   ofxiPhoneAlerts.addListener(this);
!   iPhoneSetOrientation(OFXIPHONE_ORIENTATION_LANDSCAPE_RIGHT);
!
!   ofBackground(0,0,0);
    ofSetColor(255, 0, 0);

    float i = 0;
    while (i < TWO_PI) { // make a heart
        float r = (2-2*sin(i) + sin(i)*sqrt(abs(cos(i))) / (sin(i)+1.4)) * -80;
        float x = ofGetWidth()/2 + cos(i) * r;
        float y = ofGetHeight()/2 + sin(i) * r - 100;
        line.addVertex(ofVec2f(x,y));
        i+=0.005*HALF_PI*0.5;
    }
    line.close(); // close the shape
}

void testApp::draw(){
    line.draw();
}
void testApp::touchDown(ofTouchEventArgs &touch){
    if (ofInsidePoly(touch.x, touch.y, line.getVertices())) {
        ofSetColor(255, 255, 0);
    }
}
void testApp::touchUp(ofTouchEventArgs &touch){

}
    ofSetColor(255, 0, 0);
                                                                testApp.mm

Weitere ähnliche Inhalte

Was ist angesagt?

Zoo management adri jovin
Zoo management  adri jovinZoo management  adri jovin
Zoo management adri jovin
Adri Jovin
 
Reverse Engineering: C++ "for" operator
Reverse Engineering: C++ "for" operatorReverse Engineering: C++ "for" operator
Reverse Engineering: C++ "for" operator
erithion
 

Was ist angesagt? (15)

5 Cool Things About PLSQL
5 Cool Things About PLSQL5 Cool Things About PLSQL
5 Cool Things About PLSQL
 
Sbaw090623
Sbaw090623Sbaw090623
Sbaw090623
 
Zoo management adri jovin
Zoo management  adri jovinZoo management  adri jovin
Zoo management adri jovin
 
Scala Under the Hood / ScalaSwarm
Scala Under the Hood / ScalaSwarmScala Under the Hood / ScalaSwarm
Scala Under the Hood / ScalaSwarm
 
Reverse Engineering: C++ "for" operator
Reverse Engineering: C++ "for" operatorReverse Engineering: C++ "for" operator
Reverse Engineering: C++ "for" operator
 
The Ring programming language version 1.7 book - Part 60 of 196
The Ring programming language version 1.7 book - Part 60 of 196The Ring programming language version 1.7 book - Part 60 of 196
The Ring programming language version 1.7 book - Part 60 of 196
 
Comunicação Android Arduino - JASI 2015
Comunicação Android Arduino - JASI 2015Comunicação Android Arduino - JASI 2015
Comunicação Android Arduino - JASI 2015
 
Michael kontopoulo1s
Michael kontopoulo1sMichael kontopoulo1s
Michael kontopoulo1s
 
Environmental effects - a ray tracing exercise
Environmental effects - a ray tracing exerciseEnvironmental effects - a ray tracing exercise
Environmental effects - a ray tracing exercise
 
The Ring programming language version 1.5.1 book - Part 56 of 180
The Ring programming language version 1.5.1 book - Part 56 of 180The Ring programming language version 1.5.1 book - Part 56 of 180
The Ring programming language version 1.5.1 book - Part 56 of 180
 
Throttle and Debounce Patterns in Web Apps
Throttle and Debounce Patterns in Web AppsThrottle and Debounce Patterns in Web Apps
Throttle and Debounce Patterns in Web Apps
 
Wildlife conservation project management adri jovin
Wildlife conservation project management  adri jovinWildlife conservation project management  adri jovin
Wildlife conservation project management adri jovin
 
Java awt
Java awtJava awt
Java awt
 
Vcs8
Vcs8Vcs8
Vcs8
 
Introduction to Programming @ NTHUEEECamp 2015
Introduction to Programming @ NTHUEEECamp 2015Introduction to Programming @ NTHUEEECamp 2015
Introduction to Programming @ NTHUEEECamp 2015
 

Andere mochten auch (9)

Message2
Message2Message2
Message2
 
The power of example
The power of exampleThe power of example
The power of example
 
Iphone course 1
Iphone course 1Iphone course 1
Iphone course 1
 
Planning and enjoying a vacation in alaska
Planning and enjoying a vacation in alaskaPlanning and enjoying a vacation in alaska
Planning and enjoying a vacation in alaska
 
Luke 1:26-35 -Bryan Thomson
Luke 1:26-35 -Bryan ThomsonLuke 1:26-35 -Bryan Thomson
Luke 1:26-35 -Bryan Thomson
 
SAJ @ the Movies - Princess Diaries 2 - Paul Gardner
SAJ @ the Movies - Princess Diaries 2 - Paul GardnerSAJ @ the Movies - Princess Diaries 2 - Paul Gardner
SAJ @ the Movies - Princess Diaries 2 - Paul Gardner
 
God is Closer Than You Think - Part 2 - Raewyn Gardner
God is Closer Than You Think - Part 2 - Raewyn GardnerGod is Closer Than You Think - Part 2 - Raewyn Gardner
God is Closer Than You Think - Part 2 - Raewyn Gardner
 
Of class1
Of class1Of class1
Of class1
 
Iphone course 3
Iphone course 3Iphone course 3
Iphone course 3
 

Ähnlich wie Of class3

openFrameworks – パーティクルを動かす、静的配列と動的配列 - 多摩美メディアアートII
openFrameworks – パーティクルを動かす、静的配列と動的配列 - 多摩美メディアアートIIopenFrameworks – パーティクルを動かす、静的配列と動的配列 - 多摩美メディアアートII
openFrameworks – パーティクルを動かす、静的配列と動的配列 - 多摩美メディアアートII
Atsushi Tadokoro
 
openFrameworks、サウンド機能・音響合成、ofxMaxim, ofxOsc, ofxPd, ofxSuperCollider
openFrameworks、サウンド機能・音響合成、ofxMaxim, ofxOsc, ofxPd, ofxSuperCollideropenFrameworks、サウンド機能・音響合成、ofxMaxim, ofxOsc, ofxPd, ofxSuperCollider
openFrameworks、サウンド機能・音響合成、ofxMaxim, ofxOsc, ofxPd, ofxSuperCollider
Atsushi Tadokoro
 
2011 py con
2011 py con2011 py con
2011 py con
Eing Ong
 
¡Ups! código inseguro: detección, explotación y mitigación de vulnerabilidade...
¡Ups! código inseguro: detección, explotación y mitigación de vulnerabilidade...¡Ups! código inseguro: detección, explotación y mitigación de vulnerabilidade...
¡Ups! código inseguro: detección, explotación y mitigación de vulnerabilidade...
Software Guru
 
2010 bb dev con
2010 bb dev con 2010 bb dev con
2010 bb dev con
Eing Ong
 
Unit testing in iOS featuring OCUnit, GHUnit & OCMock
Unit testing in iOS featuring OCUnit, GHUnit & OCMockUnit testing in iOS featuring OCUnit, GHUnit & OCMock
Unit testing in iOS featuring OCUnit, GHUnit & OCMock
Robot Media
 

Ähnlich wie Of class3 (20)

openFrameworks – パーティクルを動かす、静的配列と動的配列 - 多摩美メディアアートII
openFrameworks – パーティクルを動かす、静的配列と動的配列 - 多摩美メディアアートIIopenFrameworks – パーティクルを動かす、静的配列と動的配列 - 多摩美メディアアートII
openFrameworks – パーティクルを動かす、静的配列と動的配列 - 多摩美メディアアートII
 
Mobile HTML, CSS, and JavaScript
Mobile HTML, CSS, and JavaScriptMobile HTML, CSS, and JavaScript
Mobile HTML, CSS, and JavaScript
 
The Death of a Mouse
The Death of a MouseThe Death of a Mouse
The Death of a Mouse
 
golang_getting_started.pptx
golang_getting_started.pptxgolang_getting_started.pptx
golang_getting_started.pptx
 
openFrameworks、サウンド機能・音響合成、ofxMaxim, ofxOsc, ofxPd, ofxSuperCollider
openFrameworks、サウンド機能・音響合成、ofxMaxim, ofxOsc, ofxPd, ofxSuperCollideropenFrameworks、サウンド機能・音響合成、ofxMaxim, ofxOsc, ofxPd, ofxSuperCollider
openFrameworks、サウンド機能・音響合成、ofxMaxim, ofxOsc, ofxPd, ofxSuperCollider
 
2011 py con
2011 py con2011 py con
2011 py con
 
Unit2 C
Unit2 C Unit2 C
Unit2 C
 
Unit2 C
Unit2 CUnit2 C
Unit2 C
 
¡Ups! código inseguro: detección, explotación y mitigación de vulnerabilidade...
¡Ups! código inseguro: detección, explotación y mitigación de vulnerabilidade...¡Ups! código inseguro: detección, explotación y mitigación de vulnerabilidade...
¡Ups! código inseguro: detección, explotación y mitigación de vulnerabilidade...
 
Programming ppt files (final)
Programming ppt files (final)Programming ppt files (final)
Programming ppt files (final)
 
Control structure of c
Control structure of cControl structure of c
Control structure of c
 
Acciones para AmigoBot
Acciones para AmigoBotAcciones para AmigoBot
Acciones para AmigoBot
 
2010 bb dev con
2010 bb dev con 2010 bb dev con
2010 bb dev con
 
Tutorial 8 menu
Tutorial 8   menuTutorial 8   menu
Tutorial 8 menu
 
Cross-platform Native App ontwikkeling met Appcelerator
Cross-platform Native App ontwikkeling met AppceleratorCross-platform Native App ontwikkeling met Appcelerator
Cross-platform Native App ontwikkeling met Appcelerator
 
mobl
moblmobl
mobl
 
Unit testing in iOS featuring OCUnit, GHUnit & OCMock
Unit testing in iOS featuring OCUnit, GHUnit & OCMockUnit testing in iOS featuring OCUnit, GHUnit & OCMock
Unit testing in iOS featuring OCUnit, GHUnit & OCMock
 
Functuon
FunctuonFunctuon
Functuon
 
Functuon
FunctuonFunctuon
Functuon
 
Automated testing of mobile applications on multiple platforms
Automated testing of mobile applications on multiple platformsAutomated testing of mobile applications on multiple platforms
Automated testing of mobile applications on multiple platforms
 

Mehr von Janet Huang (7)

Transferring Sensing to a Mixed Virtual and Physical Experience
Transferring Sensing to a Mixed Virtual and Physical ExperienceTransferring Sensing to a Mixed Virtual and Physical Experience
Transferring Sensing to a Mixed Virtual and Physical Experience
 
Collecting a Image Label from Crowds Using Amazon Mechanical Turk
Collecting a Image Label from Crowds Using Amazon Mechanical TurkCollecting a Image Label from Crowds Using Amazon Mechanical Turk
Collecting a Image Label from Crowds Using Amazon Mechanical Turk
 
Art in the Crowd
Art in the CrowdArt in the Crowd
Art in the Crowd
 
How to Program SmartThings
How to Program SmartThingsHow to Program SmartThings
How to Program SmartThings
 
Designing physical and digital experience in social web
Designing physical and digital experience in social webDesigning physical and digital experience in social web
Designing physical and digital experience in social web
 
Iphone course 2
Iphone course 2Iphone course 2
Iphone course 2
 
Responsive web design
Responsive web designResponsive web design
Responsive web design
 

Kürzlich hochgeladen

CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
giselly40
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
Earley Information Science
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
vu2urc
 

Kürzlich hochgeladen (20)

Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
Tech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdfTech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdf
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 

Of class3

  • 1. Openframeworks x iPad Game Design (3) 黃怡靜 Janet Huang 2012.05.15
  • 2. Today’s Topic - Addons in OF - Three examples - Show unicode fonts - Play sounds - Touch polygon
  • 4. How to use addons into OF? Step 1: Create a basic OF application Step 2: Create a folder named “addons” inside project folder and put addons “ofxTrueTypeFontUC” into it Step 3: Open your project.xcodeproj and add files in addons and only keep src folder Step 4: Include the header file in testApp.h
  • 5. step 2 step 1 step 4 step 3 start coding!
  • 6. Show unicode fonts - you can’t display Japanese, Chinese...etc directly - you should use addons “ofxTrueTypeFontUC” Fonts - font type - TrueType fonts (*.ttf) - OpenType fonts (*.oft) - put them into “project/bin/data/”
  • 7. Show unicode fonts #pragma once #include "ofMain.h" #include "ofxiPhone.h" #include "ofxiPhoneExtras.h" #include "ofxTrueTypeFontUC.h" class testApp : public ofxiPhoneApp { ! public: ! void setup(); ! void update(); ! void draw(); ! void exit(); ! ! void touchDown(ofTouchEventArgs &touch); ! void touchMoved(ofTouchEventArgs &touch); ! void touchUp(ofTouchEventArgs &touch); ! void touchDoubleTap(ofTouchEventArgs &touch); ! void touchCancelled(ofTouchEventArgs &touch); ! void lostFocus(); ! void gotFocus(); ! void gotMemoryWarning(); ! void deviceOrientationChanged(int newOrientation); ofxTrueTypeFontUC myFont; ofxTrueTypeFontUC myFont2; }; testApp.h
  • 8. Show unicode fonts #include "testApp.h" void testApp::setup(){! ! // register touch events ! ofRegisterTouchEvents(this); ! ! // initialize the accelerometer ! ofxAccelerometer.setup(); ! ! //iPhoneAlerts will be sent to this. ! ofxiPhoneAlerts.addListener(this); ! ! //If you want a landscape oreintation ! iPhoneSetOrientation(OFXIPHONE_ORIENTATION_LANDSCAPE_RIGHT); ! ofBackground(0,0,0); myFont.loadFont("MSPGothic.ttf", 28); myFont2.loadFont("Sudbury_Basin_3D.ttf", 28); } void testApp::draw(){ ofSetColor(255, 0, 0); myFont.drawString("哈囉!!", 50, 100); ofSetHexColor(0xffffff); myFont2.drawString("HELLO!!", 50, 200); } testApp.mm
  • 9.
  • 10. Play sounds - sound type - .wav, .aif, .mp3, .mp2, .ogg or .raw format. - .caf (Core Audio Format) afconvert -f caff -d LEI16@44100 -c 1 sound.wav sound.caf afconvert -f caff -d LEI16@22050 -c 1 sound.wav sound.caf sample rate - put them into “project/bin/data/”
  • 11. Play sounds #pragma once #include "ofMain.h" #include "ofxiPhone.h" #include "ofxiPhoneExtras.h" class testApp : public ofxiPhoneApp { ! public: ! void setup(); ! void update(); ! void draw(); ! void exit(); ! ! void touchDown(ofTouchEventArgs &touch); ! void touchMoved(ofTouchEventArgs &touch); ! void touchUp(ofTouchEventArgs &touch); ! void touchDoubleTap(ofTouchEventArgs &touch); ! void touchCancelled(ofTouchEventArgs &touch); ! void lostFocus(); ! void gotFocus(); ! void gotMemoryWarning(); void deviceOrientationChanged(int newOrientation); ofSoundPlayer mySound; }; testApp.h
  • 12. Play sounds #include "testApp.h" void testApp::setup(){! ! // register touch events ! ofRegisterTouchEvents(this); ! ! // initialize the accelerometer ofxAccelerometer.setup(); ! ! //iPhoneAlerts will be sent to this. ! ofxiPhoneAlerts.addListener(this); ! ! //If you want a landscape oreintation ! //iPhoneSetOrientation(OFXIPHONE_ORIENTATION_LANDSCAPE_RIGHT); ! ! ofBackground(0, 0, 0); mySound.loadSound("cat.wav"); mySound.setVolume(0.75f); mySound.setMultiPlay(true); } void testApp::touchDown(ofTouchEventArgs &touch){ mySound.play(); } testApp.mm
  • 13. Touch polygon ofInsidePoly() ofInsidePoly(...) bool  ofInsidePoly(float  x,  float  y,  const  vector<  ofPoint  >  &poly) 1 (x,y) 13 14 2 3 12 4 11 5 10 6 8 9 7
  • 14. Touch polygon #pragma once #include "ofMain.h" #include "ofxiPhone.h" #include "ofxiPhoneExtras.h" class testApp : public ofxiPhoneApp { ! public: void setup(); ! void update(); ! void draw(); ! void exit(); ! ! void touchDown(ofTouchEventArgs &touch); ! void touchMoved(ofTouchEventArgs &touch); ! void touchUp(ofTouchEventArgs &touch); ! void touchDoubleTap(ofTouchEventArgs &touch); ! void touchCancelled(ofTouchEventArgs &touch); ! void lostFocus(); ! void gotFocus(); ! void gotMemoryWarning(); ! void deviceOrientationChanged(int newOrientation); ofPolyline line; }; testApp.h
  • 15. #include "testApp.h" Touch polygon void testApp::setup(){! ! ofRegisterTouchEvents(this); ! ofxAccelerometer.setup(); ! ofxiPhoneAlerts.addListener(this); ! iPhoneSetOrientation(OFXIPHONE_ORIENTATION_LANDSCAPE_RIGHT); ! ! ofBackground(0,0,0); ofSetColor(255, 0, 0); float i = 0; while (i < TWO_PI) { // make a heart float r = (2-2*sin(i) + sin(i)*sqrt(abs(cos(i))) / (sin(i)+1.4)) * -80; float x = ofGetWidth()/2 + cos(i) * r; float y = ofGetHeight()/2 + sin(i) * r - 100; line.addVertex(ofVec2f(x,y)); i+=0.005*HALF_PI*0.5; } line.close(); // close the shape } void testApp::draw(){ line.draw(); } void testApp::touchDown(ofTouchEventArgs &touch){ if (ofInsidePoly(touch.x, touch.y, line.getVertices())) { ofSetColor(255, 255, 0); } } void testApp::touchUp(ofTouchEventArgs &touch){ } ofSetColor(255, 0, 0); testApp.mm