SlideShare une entreprise Scribd logo
1  sur  15
Télécharger pour lire hors ligne
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

Contenu connexe

Tendances

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淳佑 楊
 

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

En vedette

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
 

En vedette (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
 

Similaire à 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
 

Similaire à 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
 

Plus 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
 

Plus 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
 

Dernier

Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 3652toLead Limited
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfAddepto
 
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
 
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
 
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
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc
 
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxDigital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxLoriGlavin3
 
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
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsPixlogix Infotech
 
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
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxLoriGlavin3
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024Lorenzo Miniero
 
What is Artificial Intelligence?????????
What is Artificial Intelligence?????????What is Artificial Intelligence?????????
What is Artificial Intelligence?????????blackmambaettijean
 
DSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningDSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningLars Bell
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii SoldatenkoFwdays
 
Sample pptx for embedding into website for demo
Sample pptx for embedding into website for demoSample pptx for embedding into website for demo
Sample pptx for embedding into website for demoHarshalMandlekar2
 
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxUse of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxLoriGlavin3
 
DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenHervé Boutemy
 
SALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICESSALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICESmohitsingh558521
 

Dernier (20)

Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdf
 
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
 
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
 
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
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
 
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxDigital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
 
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
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and Cons
 
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
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024
 
What is Artificial Intelligence?????????
What is Artificial Intelligence?????????What is Artificial Intelligence?????????
What is Artificial Intelligence?????????
 
DSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningDSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine Tuning
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko
 
Sample pptx for embedding into website for demo
Sample pptx for embedding into website for demoSample pptx for embedding into website for demo
Sample pptx for embedding into website for demo
 
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxUse of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
 
DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache Maven
 
SALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICESSALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICES
 

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