SlideShare una empresa de Scribd logo
1 de 15
Descargar para leer sin conexión
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

Más contenido relacionado

La actualidad más candente

5 Cool Things About PLSQL
5 Cool Things About PLSQL5 Cool Things About PLSQL
5 Cool Things About PLSQLConnor McDonald
 
Zoo management adri jovin
Zoo management  adri jovinZoo management  adri jovin
Zoo management adri jovinAdri Jovin
 
Scala Under the Hood / ScalaSwarm
Scala Under the Hood / ScalaSwarmScala Under the Hood / ScalaSwarm
Scala Under the Hood / ScalaSwarmTzofia Shiftan
 
Reverse Engineering: C++ "for" operator
Reverse Engineering: C++ "for" operatorReverse Engineering: C++ "for" operator
Reverse Engineering: C++ "for" operatorerithion
 
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 196Mahmoud Samir Fayed
 
Comunicação Android Arduino - JASI 2015
Comunicação Android Arduino - JASI 2015Comunicação Android Arduino - JASI 2015
Comunicação Android Arduino - JASI 2015Rodrigo Reis Alves
 
Environmental effects - a ray tracing exercise
Environmental effects - a ray tracing exerciseEnvironmental effects - a ray tracing exercise
Environmental effects - a ray tracing exercisePierangelo Cecchetto
 
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 180Mahmoud Samir Fayed
 
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 AppsAlmir Filho
 
Wildlife conservation project management adri jovin
Wildlife conservation project management  adri jovinWildlife conservation project management  adri jovin
Wildlife conservation project management adri jovinAdri Jovin
 
Introduction to Programming @ NTHUEEECamp 2015
Introduction to Programming @ NTHUEEECamp 2015Introduction to Programming @ NTHUEEECamp 2015
Introduction to Programming @ NTHUEEECamp 2015淳佑 楊
 

La actualidad más candente (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
 

Destacado

Message2
Message2Message2
Message2sajsaj
 
The power of example
The power of exampleThe power of example
The power of exampleJanet Huang
 
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 alaskaChandrashekhar Sathaye
 
Luke 1:26-35 -Bryan Thomson
Luke 1:26-35 -Bryan ThomsonLuke 1:26-35 -Bryan Thomson
Luke 1:26-35 -Bryan Thomsonsajsaj
 
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 Gardnersajsaj
 
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 Gardnersajsaj
 

Destacado (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
 

Similar a Of class3

openFrameworks – パーティクルを動かす、静的配列と動的配列 - 多摩美メディアアートII
openFrameworks – パーティクルを動かす、静的配列と動的配列 - 多摩美メディアアートIIopenFrameworks – パーティクルを動かす、静的配列と動的配列 - 多摩美メディアアートII
openFrameworks – パーティクルを動かす、静的配列と動的配列 - 多摩美メディアアートIIAtsushi Tadokoro
 
Mobile HTML, CSS, and JavaScript
Mobile HTML, CSS, and JavaScriptMobile HTML, CSS, and JavaScript
Mobile HTML, CSS, and JavaScriptfranksvalli
 
The Death of a Mouse
The Death of a MouseThe Death of a Mouse
The Death of a MouseGeert Bevin
 
golang_getting_started.pptx
golang_getting_started.pptxgolang_getting_started.pptx
golang_getting_started.pptxGuy Komari
 
openFrameworks、サウンド機能・音響合成、ofxMaxim, ofxOsc, ofxPd, ofxSuperCollider
openFrameworks、サウンド機能・音響合成、ofxMaxim, ofxOsc, ofxPd, ofxSuperCollideropenFrameworks、サウンド機能・音響合成、ofxMaxim, ofxOsc, ofxPd, ofxSuperCollider
openFrameworks、サウンド機能・音響合成、ofxMaxim, ofxOsc, ofxPd, ofxSuperColliderAtsushi Tadokoro
 
2011 py con
2011 py con2011 py con
2011 py conEing 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
 
Programming ppt files (final)
Programming ppt files (final)Programming ppt files (final)
Programming ppt files (final)yap_raiza
 
Control structure of c
Control structure of cControl structure of c
Control structure of cKomal Kotak
 
Acciones para AmigoBot
Acciones para AmigoBotAcciones para AmigoBot
Acciones para AmigoBotjhonsoomelol
 
2010 bb dev con
2010 bb dev con 2010 bb dev con
2010 bb dev con Eing Ong
 
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 AppceleratorFokke Zandbergen
 
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 & OCMockRobot Media
 
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 platformsjobandesther
 

Similar a 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
 

Más de Janet Huang

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 ExperienceJanet Huang
 
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 TurkJanet Huang
 
Art in the Crowd
Art in the CrowdArt in the Crowd
Art in the CrowdJanet Huang
 
How to Program SmartThings
How to Program SmartThingsHow to Program SmartThings
How to Program SmartThingsJanet Huang
 
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 webJanet Huang
 
Responsive web design
Responsive web designResponsive web design
Responsive web designJanet Huang
 

Más de 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
 

Último

TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024Lonnie McRorey
 
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024BookNet Canada
 
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxA Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxLoriGlavin3
 
Scale your database traffic with Read & Write split using MySQL Router
Scale your database traffic with Read & Write split using MySQL RouterScale your database traffic with Read & Write split using MySQL Router
Scale your database traffic with Read & Write split using MySQL RouterMydbops
 
Long journey of Ruby standard library at RubyConf AU 2024
Long journey of Ruby standard library at RubyConf AU 2024Long journey of Ruby standard library at RubyConf AU 2024
Long journey of Ruby standard library at RubyConf AU 2024Hiroshi SHIBATA
 
[Webinar] SpiraTest - Setting New Standards in Quality Assurance
[Webinar] SpiraTest - Setting New Standards in Quality Assurance[Webinar] SpiraTest - Setting New Standards in Quality Assurance
[Webinar] SpiraTest - Setting New Standards in Quality AssuranceInflectra
 
Testing tools and AI - ideas what to try with some tool examples
Testing tools and AI - ideas what to try with some tool examplesTesting tools and AI - ideas what to try with some tool examples
Testing tools and AI - ideas what to try with some tool examplesKari Kakkonen
 
Assure Ecommerce and Retail Operations Uptime with ThousandEyes
Assure Ecommerce and Retail Operations Uptime with ThousandEyesAssure Ecommerce and Retail Operations Uptime with ThousandEyes
Assure Ecommerce and Retail Operations Uptime with ThousandEyesThousandEyes
 
The State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxThe State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxLoriGlavin3
 
A Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software DevelopersA Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software DevelopersNicole Novielli
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsSergiu Bodiu
 
What is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdfWhat is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdfMounikaPolabathina
 
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024BookNet Canada
 
Decarbonising Buildings: Making a net-zero built environment a reality
Decarbonising Buildings: Making a net-zero built environment a realityDecarbonising Buildings: Making a net-zero built environment a reality
Decarbonising Buildings: Making a net-zero built environment a realityIES VE
 
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...Wes McKinney
 
2024 April Patch Tuesday
2024 April Patch Tuesday2024 April Patch Tuesday
2024 April Patch TuesdayIvanti
 
Generative Artificial Intelligence: How generative AI works.pdf
Generative Artificial Intelligence: How generative AI works.pdfGenerative Artificial Intelligence: How generative AI works.pdf
Generative Artificial Intelligence: How generative AI works.pdfIngrid Airi González
 
Potential of AI (Generative AI) in Business: Learnings and Insights
Potential of AI (Generative AI) in Business: Learnings and InsightsPotential of AI (Generative AI) in Business: Learnings and Insights
Potential of AI (Generative AI) in Business: Learnings and InsightsRavi Sanghani
 
Moving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfMoving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfLoriGlavin3
 
So einfach geht modernes Roaming fuer Notes und Nomad.pdf
So einfach geht modernes Roaming fuer Notes und Nomad.pdfSo einfach geht modernes Roaming fuer Notes und Nomad.pdf
So einfach geht modernes Roaming fuer Notes und Nomad.pdfpanagenda
 

Último (20)

TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024
 
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
 
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxA Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
 
Scale your database traffic with Read & Write split using MySQL Router
Scale your database traffic with Read & Write split using MySQL RouterScale your database traffic with Read & Write split using MySQL Router
Scale your database traffic with Read & Write split using MySQL Router
 
Long journey of Ruby standard library at RubyConf AU 2024
Long journey of Ruby standard library at RubyConf AU 2024Long journey of Ruby standard library at RubyConf AU 2024
Long journey of Ruby standard library at RubyConf AU 2024
 
[Webinar] SpiraTest - Setting New Standards in Quality Assurance
[Webinar] SpiraTest - Setting New Standards in Quality Assurance[Webinar] SpiraTest - Setting New Standards in Quality Assurance
[Webinar] SpiraTest - Setting New Standards in Quality Assurance
 
Testing tools and AI - ideas what to try with some tool examples
Testing tools and AI - ideas what to try with some tool examplesTesting tools and AI - ideas what to try with some tool examples
Testing tools and AI - ideas what to try with some tool examples
 
Assure Ecommerce and Retail Operations Uptime with ThousandEyes
Assure Ecommerce and Retail Operations Uptime with ThousandEyesAssure Ecommerce and Retail Operations Uptime with ThousandEyes
Assure Ecommerce and Retail Operations Uptime with ThousandEyes
 
The State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxThe State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptx
 
A Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software DevelopersA Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software Developers
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platforms
 
What is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdfWhat is DBT - The Ultimate Data Build Tool.pdf
What is DBT - The Ultimate Data Build Tool.pdf
 
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
 
Decarbonising Buildings: Making a net-zero built environment a reality
Decarbonising Buildings: Making a net-zero built environment a realityDecarbonising Buildings: Making a net-zero built environment a reality
Decarbonising Buildings: Making a net-zero built environment a reality
 
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...
 
2024 April Patch Tuesday
2024 April Patch Tuesday2024 April Patch Tuesday
2024 April Patch Tuesday
 
Generative Artificial Intelligence: How generative AI works.pdf
Generative Artificial Intelligence: How generative AI works.pdfGenerative Artificial Intelligence: How generative AI works.pdf
Generative Artificial Intelligence: How generative AI works.pdf
 
Potential of AI (Generative AI) in Business: Learnings and Insights
Potential of AI (Generative AI) in Business: Learnings and InsightsPotential of AI (Generative AI) in Business: Learnings and Insights
Potential of AI (Generative AI) in Business: Learnings and Insights
 
Moving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfMoving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdf
 
So einfach geht modernes Roaming fuer Notes und Nomad.pdf
So einfach geht modernes Roaming fuer Notes und Nomad.pdfSo einfach geht modernes Roaming fuer Notes und Nomad.pdf
So einfach geht modernes Roaming fuer Notes und Nomad.pdf
 

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