SlideShare a Scribd company logo
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;

}

More Related Content

What's hot

Graphics programs
Graphics programsGraphics programs
Graphics programs
NAVYA 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 210
Mahmoud Samir Fayed
 
Quality Python Homework Help
Quality Python Homework HelpQuality Python Homework Help
Quality Python Homework Help
Python Homework Help
 
TDD per Webapps
TDD per WebappsTDD per Webapps
TDD per Webapps
CarloBottiglieri
 
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-PART2
vikram mahendra
 

What's hot (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 to Of class1

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 Tutorial
antiw
 
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
footstatus
 
Intro to computer vision in .net
Intro to computer vision in .netIntro to computer vision in .net
Intro to computer vision in .net
Stephen Lorello
 
Leaving Flatland: getting started with WebGL
Leaving Flatland: getting started with WebGLLeaving Flatland: getting started with WebGL
Leaving Flatland: getting started with WebGL
gerbille
 
Java awt
Java awtJava 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 processingChu Lam
 
openFrameworks 007 - graphics
openFrameworks 007 - graphicsopenFrameworks 007 - graphics
openFrameworks 007 - graphicsroxlu
 
"Quantum" performance effects
"Quantum" performance effects"Quantum" performance effects
"Quantum" performance effects
Sergey 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
 
mobl
moblmobl
mobl
zefhemel
 

Similar to Of class1 (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
 

More from 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 Experience
Janet 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 Turk
Janet Huang
 
Art in the Crowd
Art in the CrowdArt in the Crowd
Art in the Crowd
Janet Huang
 
How to Program SmartThings
How to Program SmartThingsHow to Program SmartThings
How to Program SmartThings
Janet 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 web
Janet Huang
 
The power of example
The power of exampleThe power of example
The power of example
Janet Huang
 
Responsive web design
Responsive web designResponsive web design
Responsive web design
Janet Huang
 

More from 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
 

Recently uploaded

Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
BookNet Canada
 
Secstrike : Reverse Engineering & Pwnable tools for CTF.pptx
Secstrike : Reverse Engineering & Pwnable tools for CTF.pptxSecstrike : Reverse Engineering & Pwnable tools for CTF.pptx
Secstrike : Reverse Engineering & Pwnable tools for CTF.pptx
nkrafacyberclub
 
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdfSmart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
91mobiles
 
DevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA ConnectDevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA Connect
Kari Kakkonen
 
Generative AI Deep Dive: Advancing from Proof of Concept to Production
Generative AI Deep Dive: Advancing from Proof of Concept to ProductionGenerative AI Deep Dive: Advancing from Proof of Concept to Production
Generative AI Deep Dive: Advancing from Proof of Concept to Production
Aggregage
 
20240607 QFM018 Elixir Reading List May 2024
20240607 QFM018 Elixir Reading List May 202420240607 QFM018 Elixir Reading List May 2024
20240607 QFM018 Elixir Reading List May 2024
Matthew Sinclair
 
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 previewState of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
Prayukth K V
 
Monitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR EventsMonitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR Events
Ana-Maria Mihalceanu
 
Uni Systems Copilot event_05062024_C.Vlachos.pdf
Uni Systems Copilot event_05062024_C.Vlachos.pdfUni Systems Copilot event_05062024_C.Vlachos.pdf
Uni Systems Copilot event_05062024_C.Vlachos.pdf
Uni Systems S.M.S.A.
 
By Design, not by Accident - Agile Venture Bolzano 2024
By Design, not by Accident - Agile Venture Bolzano 2024By Design, not by Accident - Agile Venture Bolzano 2024
By Design, not by Accident - Agile Venture Bolzano 2024
Pierluigi Pugliese
 
A tale of scale & speed: How the US Navy is enabling software delivery from l...
A tale of scale & speed: How the US Navy is enabling software delivery from l...A tale of scale & speed: How the US Navy is enabling software delivery from l...
A tale of scale & speed: How the US Navy is enabling software delivery from l...
sonjaschweigert1
 
PHP Frameworks: I want to break free (IPC Berlin 2024)
PHP Frameworks: I want to break free (IPC Berlin 2024)PHP Frameworks: I want to break free (IPC Berlin 2024)
PHP Frameworks: I want to break free (IPC Berlin 2024)
Ralf Eggert
 
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdfFIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance
 
Removing Uninteresting Bytes in Software Fuzzing
Removing Uninteresting Bytes in Software FuzzingRemoving Uninteresting Bytes in Software Fuzzing
Removing Uninteresting Bytes in Software Fuzzing
Aftab Hussain
 
SAP Sapphire 2024 - ASUG301 building better apps with SAP Fiori.pdf
SAP Sapphire 2024 - ASUG301 building better apps with SAP Fiori.pdfSAP Sapphire 2024 - ASUG301 building better apps with SAP Fiori.pdf
SAP Sapphire 2024 - ASUG301 building better apps with SAP Fiori.pdf
Peter Spielvogel
 
Epistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI supportEpistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI support
Alan Dix
 
National Security Agency - NSA mobile device best practices
National Security Agency - NSA mobile device best practicesNational Security Agency - NSA mobile device best practices
National Security Agency - NSA mobile device best practices
Quotidiano Piemontese
 
Microsoft - Power Platform_G.Aspiotis.pdf
Microsoft - Power Platform_G.Aspiotis.pdfMicrosoft - Power Platform_G.Aspiotis.pdf
Microsoft - Power Platform_G.Aspiotis.pdf
Uni Systems S.M.S.A.
 
UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4
DianaGray10
 
GraphSummit Singapore | Enhancing Changi Airport Group's Passenger Experience...
GraphSummit Singapore | Enhancing Changi Airport Group's Passenger Experience...GraphSummit Singapore | Enhancing Changi Airport Group's Passenger Experience...
GraphSummit Singapore | Enhancing Changi Airport Group's Passenger Experience...
Neo4j
 

Recently uploaded (20)

Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
 
Secstrike : Reverse Engineering & Pwnable tools for CTF.pptx
Secstrike : Reverse Engineering & Pwnable tools for CTF.pptxSecstrike : Reverse Engineering & Pwnable tools for CTF.pptx
Secstrike : Reverse Engineering & Pwnable tools for CTF.pptx
 
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdfSmart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
 
DevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA ConnectDevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA Connect
 
Generative AI Deep Dive: Advancing from Proof of Concept to Production
Generative AI Deep Dive: Advancing from Proof of Concept to ProductionGenerative AI Deep Dive: Advancing from Proof of Concept to Production
Generative AI Deep Dive: Advancing from Proof of Concept to Production
 
20240607 QFM018 Elixir Reading List May 2024
20240607 QFM018 Elixir Reading List May 202420240607 QFM018 Elixir Reading List May 2024
20240607 QFM018 Elixir Reading List May 2024
 
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 previewState of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
 
Monitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR EventsMonitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR Events
 
Uni Systems Copilot event_05062024_C.Vlachos.pdf
Uni Systems Copilot event_05062024_C.Vlachos.pdfUni Systems Copilot event_05062024_C.Vlachos.pdf
Uni Systems Copilot event_05062024_C.Vlachos.pdf
 
By Design, not by Accident - Agile Venture Bolzano 2024
By Design, not by Accident - Agile Venture Bolzano 2024By Design, not by Accident - Agile Venture Bolzano 2024
By Design, not by Accident - Agile Venture Bolzano 2024
 
A tale of scale & speed: How the US Navy is enabling software delivery from l...
A tale of scale & speed: How the US Navy is enabling software delivery from l...A tale of scale & speed: How the US Navy is enabling software delivery from l...
A tale of scale & speed: How the US Navy is enabling software delivery from l...
 
PHP Frameworks: I want to break free (IPC Berlin 2024)
PHP Frameworks: I want to break free (IPC Berlin 2024)PHP Frameworks: I want to break free (IPC Berlin 2024)
PHP Frameworks: I want to break free (IPC Berlin 2024)
 
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdfFIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
 
Removing Uninteresting Bytes in Software Fuzzing
Removing Uninteresting Bytes in Software FuzzingRemoving Uninteresting Bytes in Software Fuzzing
Removing Uninteresting Bytes in Software Fuzzing
 
SAP Sapphire 2024 - ASUG301 building better apps with SAP Fiori.pdf
SAP Sapphire 2024 - ASUG301 building better apps with SAP Fiori.pdfSAP Sapphire 2024 - ASUG301 building better apps with SAP Fiori.pdf
SAP Sapphire 2024 - ASUG301 building better apps with SAP Fiori.pdf
 
Epistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI supportEpistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI support
 
National Security Agency - NSA mobile device best practices
National Security Agency - NSA mobile device best practicesNational Security Agency - NSA mobile device best practices
National Security Agency - NSA mobile device best practices
 
Microsoft - Power Platform_G.Aspiotis.pdf
Microsoft - Power Platform_G.Aspiotis.pdfMicrosoft - Power Platform_G.Aspiotis.pdf
Microsoft - Power Platform_G.Aspiotis.pdf
 
UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4
 
GraphSummit Singapore | Enhancing Changi Airport Group's Passenger Experience...
GraphSummit Singapore | Enhancing Changi Airport Group's Passenger Experience...GraphSummit Singapore | Enhancing Changi Airport Group's Passenger Experience...
GraphSummit Singapore | Enhancing Changi Airport Group's Passenger Experience...
 

Of class1

  • 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; }