SlideShare una empresa de Scribd logo
1 de 19
Descargar para leer sin conexión
Openframeworks
         x iPad Game Design (1)




黃怡靜
Janet Huang
2012.05.01
Three main things today...
   - How to show an image in iPhone/iPad?
   - How to change an images on touch?
   - How to create animation with multiple
   images?


Other one thing...
    - Testing multitouch using tangible object
http://www.openframeworks.cc/



openFrameworks is an open source C++
toolkit for creative coding.




                                http://www.delicious.com/stacks/view/Fuhl88
OF component
iPhone/iPad application using OF

                        using c++

      iPhone/iPad app

           main.mm
                                declaration
          testApp.h             (parameter, method)


         testApp.mm             implementation
How to start?
  1. create a copy of emptyExample in apps folder
  2. rename the folder and .xcodeproj file
  3. open the project
  4. rename target
  5. make sure it builds and runs



                put your project in the right position
#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);

};




                                                            testApp.h
#include "testApp.h"

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

//--------------------------------------------------------------

                                                   loop            update
void testApp::update(){

}

//--------------------------------------------------------------

                                                   loop            draw
void testApp::draw(){
!
}

//--------------------------------------------------------------
void testApp::exit(){

}

                                                               testApp.mm
//--------------------------------------------------------------
void testApp::touchDown(ofTouchEventArgs &touch){

}
                                                               touch event
//--------------------------------------------------------------
void testApp::touchMoved(ofTouchEventArgs &touch){

}

//--------------------------------------------------------------
void testApp::touchUp(ofTouchEventArgs &touch){

}

//--------------------------------------------------------------
void testApp::touchDoubleTap(ofTouchEventArgs &touch){

}

//--------------------------------------------------------------
void testApp::lostFocus(){

}
                                                               alert handler
//--------------------------------------------------------------
void testApp::gotFocus(){

}

//--------------------------------------------------------------
void testApp::gotMemoryWarning(){

}

//--------------------------------------------------------------
void testApp::deviceOrientationChanged(int newOrientation){

}


//--------------------------------------------------------------

                                                                   testApp.mm
void testApp::touchCancelled(ofTouchEventArgs& args){

}
Try to build and run an emptyExample
iPhone/iPad screenshots

                                iPad
                                screen size: 1024x768
                                resolution: 72 ppi
                                icon size: 72x72 px




                  iPhone
                  screen size: 320x480 (640x960)
                  resolution: 72 ppi
                  icon size: 57x57 px
Orientations




         Portrait        Upside Down




        Landscape Left    Landscape Right
1. show an image

  testApp.h
          ofImage myImage;

  testApp.mm                                               setup()

          myImage.loadImage("images/creature1.png");


           ofEnableAlphaBlending();
           myImage.draw(100, 100);
                                                     draw()
  image type: PNG, JPEG, TIFF, BMP, GIF
  position: [project]/bin/data/
       http://www.openframeworks.cc/documentation/graphics/ofImage_.html
1024

      (0,0)
768              (100,100)



                                   image height




                     image width
2. change an image on touch
                                           checking flag
   - bool touched (true / false)
     touched = false;
     imageA.loadImage("images/creature1.png");
     imageB.loadImage("images/creature3.png");     setup()

      void testApp::draw(){
      ! if(touched)
              imageA.draw(100,100);
          else
              imageB.draw(100,100);
      }

      void testApp::touchDown(ofTouchEventArgs &touch){
          touched = true;
      }

      void testApp::touchUp(ofTouchEventArgs &touch){
          touched = false;
      }
Array              index

       x[0] x[1] x[2] x[3] x[4]
                                                                     value


   4           2                13            1                  5

  int x[5]; declare a array x
  x[0] = 4 assign value into array x   OR             int x[5] = {4, 2, 13, 1, 5};
  x[1] = 2
  x[2] = 13
  x[3] = 1
  x[4] = 5                             John       Amy       Mike      Cindy   David

                                        0         1          2          3       4
For-loop

                    initial   condition   addendum
            for (int i = 0; i < 10; i++) {

                 printf("Hi: %i", i);

            }




   print array x
     for (int i = 0; i < 5; i++) {

           printf("print x[%i]= %i", x[i]);

     }
3. create animations using multiple images


        x[0] x[1] x[2] x[3] x[4]




   image1    image2      image3    image4    image5




   #define BACKFRAMENUM 10
                                     number of images

   ofImage backImage[BACKFRAMENUM];
for (int i = 0; i < BACKFRAMENUM; i++) {
        char char1[32];                              setup()
         sprintf(char1, "images/background%d.png", i+1);
         backImage[i].loadImage(char1);
    }




void testApp::draw(){
!
    ofEnableAlphaBlending();
    backImage[currentFrame].draw(0, 0);
                                                    draw()
        currentFrame++;
        if (currentFrame > BACKFRAMENUM - 1)
            currentFrame = 0;

}

Más contenido relacionado

La actualidad más candente

Graphics programs
Graphics programsGraphics programs
Graphics programsNAVYA RAO
 
TensorFlow 深度學習快速上手班--電腦視覺應用
TensorFlow 深度學習快速上手班--電腦視覺應用TensorFlow 深度學習快速上手班--電腦視覺應用
TensorFlow 深度學習快速上手班--電腦視覺應用Mark Chang
 
The Ring programming language version 1.9 book - Part 65 of 210
The Ring programming language version 1.9 book - Part 65 of 210The Ring programming language version 1.9 book - Part 65 of 210
The Ring programming language version 1.9 book - Part 65 of 210Mahmoud Samir Fayed
 
Snapshot testing by Anna Doubkova
Snapshot testing by Anna Doubkova Snapshot testing by Anna Doubkova
Snapshot testing by Anna Doubkova React London 2017
 
OPERATOR IN PYTHON-PART2
OPERATOR IN PYTHON-PART2OPERATOR IN PYTHON-PART2
OPERATOR IN PYTHON-PART2vikram mahendra
 

La actualidad más candente (8)

Graphics programs
Graphics programsGraphics programs
Graphics programs
 
TensorFlow 深度學習快速上手班--電腦視覺應用
TensorFlow 深度學習快速上手班--電腦視覺應用TensorFlow 深度學習快速上手班--電腦視覺應用
TensorFlow 深度學習快速上手班--電腦視覺應用
 
The Ring programming language version 1.9 book - Part 65 of 210
The Ring programming language version 1.9 book - Part 65 of 210The Ring programming language version 1.9 book - Part 65 of 210
The Ring programming language version 1.9 book - Part 65 of 210
 
Quality Python Homework Help
Quality Python Homework HelpQuality Python Homework Help
Quality Python Homework Help
 
My favorite slides
My favorite slidesMy favorite slides
My favorite slides
 
TDD per Webapps
TDD per WebappsTDD per Webapps
TDD per Webapps
 
Snapshot testing by Anna Doubkova
Snapshot testing by Anna Doubkova Snapshot testing by Anna Doubkova
Snapshot testing by Anna Doubkova
 
OPERATOR IN PYTHON-PART2
OPERATOR IN PYTHON-PART2OPERATOR IN PYTHON-PART2
OPERATOR IN PYTHON-PART2
 

Similar a iPad Game Design Using Openframeworks

2011 py con
2011 py con2011 py con
2011 py conEing Ong
 
2010 bb dev con
2010 bb dev con 2010 bb dev con
2010 bb dev con Eing Ong
 
XebiCon'17 : Faites chauffer les neurones de votre Smartphone avec du Deep Le...
XebiCon'17 : Faites chauffer les neurones de votre Smartphone avec du Deep Le...XebiCon'17 : Faites chauffer les neurones de votre Smartphone avec du Deep Le...
XebiCon'17 : Faites chauffer les neurones de votre Smartphone avec du Deep Le...Publicis Sapient Engineering
 
HTML5って必要?
HTML5って必要?HTML5って必要?
HTML5って必要?GCS2013
 
Open Cv 2005 Q4 Tutorial
Open Cv 2005 Q4 TutorialOpen Cv 2005 Q4 Tutorial
Open Cv 2005 Q4 Tutorialantiw
 
write a MATLAB GUI program that implements an ultrasound image viewi.pdf
write a MATLAB GUI program that implements an ultrasound image viewi.pdfwrite a MATLAB GUI program that implements an ultrasound image viewi.pdf
write a MATLAB GUI program that implements an ultrasound image viewi.pdffootstatus
 
Intro to computer vision in .net
Intro to computer vision in .netIntro to computer vision in .net
Intro to computer vision in .netStephen Lorello
 
Leaving Flatland: getting started with WebGL
Leaving Flatland: getting started with WebGLLeaving Flatland: getting started with WebGL
Leaving Flatland: getting started with WebGLgerbille
 
A basic introduction to open cv for image processing
A basic introduction to open cv for image processingA basic introduction to open cv for image processing
A basic introduction to open cv for image processingChu Lam
 
openFrameworks 007 - graphics
openFrameworks 007 - graphicsopenFrameworks 007 - graphics
openFrameworks 007 - graphicsroxlu
 
"Quantum" performance effects
"Quantum" performance effects"Quantum" performance effects
"Quantum" performance effectsSergey Kuksenko
 
Gdc09 Minigames
Gdc09 MinigamesGdc09 Minigames
Gdc09 MinigamesSusan Gold
 
14multithreaded Graphics
14multithreaded Graphics14multithreaded Graphics
14multithreaded GraphicsAdil Jafri
 
Useful Tools for Making Video Games - XNA (2008)
Useful Tools for Making Video Games - XNA (2008)Useful Tools for Making Video Games - XNA (2008)
Useful Tools for Making Video Games - XNA (2008)Korhan Bircan
 

Similar a iPad Game Design Using Openframeworks (20)

Of class2
Of class2Of class2
Of class2
 
2011 py con
2011 py con2011 py con
2011 py con
 
2010 bb dev con
2010 bb dev con 2010 bb dev con
2010 bb dev con
 
XebiCon'17 : Faites chauffer les neurones de votre Smartphone avec du Deep Le...
XebiCon'17 : Faites chauffer les neurones de votre Smartphone avec du Deep Le...XebiCon'17 : Faites chauffer les neurones de votre Smartphone avec du Deep Le...
XebiCon'17 : Faites chauffer les neurones de votre Smartphone avec du Deep Le...
 
HTML5って必要?
HTML5って必要?HTML5って必要?
HTML5って必要?
 
Open Cv 2005 Q4 Tutorial
Open Cv 2005 Q4 TutorialOpen Cv 2005 Q4 Tutorial
Open Cv 2005 Q4 Tutorial
 
write a MATLAB GUI program that implements an ultrasound image viewi.pdf
write a MATLAB GUI program that implements an ultrasound image viewi.pdfwrite a MATLAB GUI program that implements an ultrasound image viewi.pdf
write a MATLAB GUI program that implements an ultrasound image viewi.pdf
 
Real life XNA
Real life XNAReal life XNA
Real life XNA
 
Intro to computer vision in .net
Intro to computer vision in .netIntro to computer vision in .net
Intro to computer vision in .net
 
Leaving Flatland: getting started with WebGL
Leaving Flatland: getting started with WebGLLeaving Flatland: getting started with WebGL
Leaving Flatland: getting started with WebGL
 
Java awt
Java awtJava awt
Java awt
 
A basic introduction to open cv for image processing
A basic introduction to open cv for image processingA basic introduction to open cv for image processing
A basic introduction to open cv for image processing
 
openFrameworks 007 - graphics
openFrameworks 007 - graphicsopenFrameworks 007 - graphics
openFrameworks 007 - graphics
 
"Quantum" performance effects
"Quantum" performance effects"Quantum" performance effects
"Quantum" performance effects
 
Gdc09 Minigames
Gdc09 MinigamesGdc09 Minigames
Gdc09 Minigames
 
14multithreaded Graphics
14multithreaded Graphics14multithreaded Graphics
14multithreaded Graphics
 
Useful Tools for Making Video Games - XNA (2008)
Useful Tools for Making Video Games - XNA (2008)Useful Tools for Making Video Games - XNA (2008)
Useful Tools for Making Video Games - XNA (2008)
 
Android workshop
Android workshopAndroid workshop
Android workshop
 
Of class3
Of class3Of class3
Of class3
 
mobl
moblmobl
mobl
 

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
 
The power of example
The power of exampleThe power of example
The power of exampleJanet Huang
 
Responsive web design
Responsive web designResponsive web design
Responsive web designJanet Huang
 

Más de Janet Huang (10)

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 3
Iphone course 3Iphone course 3
Iphone course 3
 
Iphone course 2
Iphone course 2Iphone course 2
Iphone course 2
 
Iphone course 1
Iphone course 1Iphone course 1
Iphone course 1
 
The power of example
The power of exampleThe power of example
The power of example
 
Responsive web design
Responsive web designResponsive web design
Responsive web design
 

Último

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 slidevu2urc
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationRadu Cotescu
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking MenDelhi Call girls
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Scriptwesley chun
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationMichael W. Hawkins
 
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.pdfEnterprise Knowledge
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024Results
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxKatpro Technologies
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024The Digital Insurer
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...Neo4j
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CVKhem
 
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...Miguel Araújo
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
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 WorkerThousandEyes
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Enterprise Knowledge
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking MenDelhi Call girls
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxMalak Abu Hammad
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountPuma Security, LLC
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationSafe Software
 

Último (20)

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
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
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
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CV
 
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...
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024
 
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
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptx
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path Mount
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 

iPad Game Design Using Openframeworks

  • 1. Openframeworks x iPad Game Design (1) 黃怡靜 Janet Huang 2012.05.01
  • 2. Three main things today... - How to show an image in iPhone/iPad? - How to change an images on touch? - How to create animation with multiple images? Other one thing... - Testing multitouch using tangible object
  • 3. http://www.openframeworks.cc/ openFrameworks is an open source C++ toolkit for creative coding. http://www.delicious.com/stacks/view/Fuhl88
  • 5. iPhone/iPad application using OF using c++ iPhone/iPad app main.mm declaration testApp.h (parameter, method) testApp.mm implementation
  • 6. How to start? 1. create a copy of emptyExample in apps folder 2. rename the folder and .xcodeproj file 3. open the project 4. rename target 5. make sure it builds and runs put your project in the right position
  • 7. #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); }; testApp.h
  • 8. #include "testApp.h" //-------------------------------------------------------------- void testApp::setup(){! ! // register touch events setup ! ofRegisterTouchEvents(this); ! ! // initialize the accelerometer execute only once ! ofxAccelerometer.setup(); ! ! //iPhoneAlerts will be sent to this. ! ofxiPhoneAlerts.addListener(this); ! ! //If you want a landscape oreintation ! //iPhoneSetOrientation(OFXIPHONE_ORIENTATION_LANDSCAPE_RIGHT); ! ! ofBackground(127,127,127); } //-------------------------------------------------------------- loop update void testApp::update(){ } //-------------------------------------------------------------- loop draw void testApp::draw(){ ! } //-------------------------------------------------------------- void testApp::exit(){ } testApp.mm
  • 9. //-------------------------------------------------------------- void testApp::touchDown(ofTouchEventArgs &touch){ } touch event //-------------------------------------------------------------- void testApp::touchMoved(ofTouchEventArgs &touch){ } //-------------------------------------------------------------- void testApp::touchUp(ofTouchEventArgs &touch){ } //-------------------------------------------------------------- void testApp::touchDoubleTap(ofTouchEventArgs &touch){ } //-------------------------------------------------------------- void testApp::lostFocus(){ } alert handler //-------------------------------------------------------------- void testApp::gotFocus(){ } //-------------------------------------------------------------- void testApp::gotMemoryWarning(){ } //-------------------------------------------------------------- void testApp::deviceOrientationChanged(int newOrientation){ } //-------------------------------------------------------------- testApp.mm void testApp::touchCancelled(ofTouchEventArgs& args){ }
  • 10. Try to build and run an emptyExample
  • 11. iPhone/iPad screenshots iPad screen size: 1024x768 resolution: 72 ppi icon size: 72x72 px iPhone screen size: 320x480 (640x960) resolution: 72 ppi icon size: 57x57 px
  • 12. Orientations Portrait Upside Down Landscape Left Landscape Right
  • 13. 1. show an image testApp.h ofImage myImage; testApp.mm setup() myImage.loadImage("images/creature1.png"); ofEnableAlphaBlending(); myImage.draw(100, 100); draw() image type: PNG, JPEG, TIFF, BMP, GIF position: [project]/bin/data/ http://www.openframeworks.cc/documentation/graphics/ofImage_.html
  • 14. 1024 (0,0) 768 (100,100) image height image width
  • 15. 2. change an image on touch checking flag - bool touched (true / false) touched = false; imageA.loadImage("images/creature1.png"); imageB.loadImage("images/creature3.png"); setup() void testApp::draw(){ ! if(touched) imageA.draw(100,100); else imageB.draw(100,100); } void testApp::touchDown(ofTouchEventArgs &touch){ touched = true; } void testApp::touchUp(ofTouchEventArgs &touch){ touched = false; }
  • 16. Array index x[0] x[1] x[2] x[3] x[4] value 4 2 13 1 5 int x[5]; declare a array x x[0] = 4 assign value into array x OR int x[5] = {4, 2, 13, 1, 5}; x[1] = 2 x[2] = 13 x[3] = 1 x[4] = 5 John Amy Mike Cindy David 0 1 2 3 4
  • 17. For-loop initial condition addendum for (int i = 0; i < 10; i++) { printf("Hi: %i", i); } print array x for (int i = 0; i < 5; i++) { printf("print x[%i]= %i", x[i]); }
  • 18. 3. create animations using multiple images x[0] x[1] x[2] x[3] x[4] image1 image2 image3 image4 image5 #define BACKFRAMENUM 10 number of images ofImage backImage[BACKFRAMENUM];
  • 19. for (int i = 0; i < BACKFRAMENUM; i++) { char char1[32]; setup() sprintf(char1, "images/background%d.png", i+1); backImage[i].loadImage(char1); } void testApp::draw(){ ! ofEnableAlphaBlending(); backImage[currentFrame].draw(0, 0); draw() currentFrame++; if (currentFrame > BACKFRAMENUM - 1) currentFrame = 0; }