3 Multimedia Programming with C++ and Multimedia Frameworks



Similar documents
3 Multimedia Programming with C++ and Multimedia Frameworks

6 Images, Vector Graphics, and Scenes

2! Multimedia Programming with! Python and SDL

Outline. 1.! Development Platforms for Multimedia Programming!

Write Your Angry Bird Game on Tizen for Fun and Profit. Lu Guanqun Intel Corporation

Rapid Game Development Using Cocos2D-JS

Project 2: Character Animation Due Date: Friday, March 10th, 11:59 PM

Outline. 1.! Development Platforms for Multimedia Programming!

Sprite Kit Programming Guide

the gamedesigninitiative at cornell university Lecture 1 Course Overview

U.Rahamathunnisa 1, S. Pragadeeswaran 2 *Assistant Professor, SITE, VIT University, Vellore. **MS(SE) Student, SITE, VIT University, Vellore.

KIVY - A Framework for Natural User Interfaces

CROSS-PLATFORM MOBILE APPLICATION DEVELOPMENT. Roman Khandozhenko

Mobile Application Development

A little code goes a long way Cross-platform game development with Lua. Ivan Beliy, Software Engineer

Affdex SDK for Windows!

History OOP languages Year Language 1967 Simula Smalltalk

sqlpp11 - An SQL Library Worthy of Modern C++

Introduction to Computer Graphics with WebGL

X-GSD: Cross-Platform Game Skeleton (Data-Driven)

MEAP Edition Manning Early Access Program Hello! ios Development version 14

ios Audio Programming Guide

Teaching App Development with Swift Course Materials Overview

Reading and Writing PCD Files The PCD File Format The Grabber Interface Writing a Custom Grabber PCL :: I/O. Suat Gedikli, Nico Blodow

ios Design Patterns Jackie Myrose CSCI 5448 Fall 2012

6waves Limited. Internship

How To Use Ios 5

INTRODUCTION TO OBJECTIVE-C CSCI 4448/5448: OBJECT-ORIENTED ANALYSIS & DESIGN LECTURE 12 09/29/2011

The Darwin Game 2.0 Programming Guide

2. About iphone ios 5 Development Essentials. 5. Joining the Apple ios Developer Program

Star Micronics Cloud Services ios SDK User's Manual

Full version is >>> HERE <<<

Computer Science. 232 Computer Science. Degrees and Certificates Awarded. A.S. Degree Requirements. Program Student Outcomes. Department Offices

How To Develop An App For Ios (Windows)

Java game programming. Game engines. Fayolle Pierre-Alain

CS506 Web Design and Development Solved Online Quiz No. 01

Creating Animated Apps

Shader Model 3.0. Ashu Rege. NVIDIA Developer Technology Group

Outline Basic concepts of Python language

The 8 th International Scientific Conference elearning and software for Education Bucharest, April 26-27, / X

Help Software Design of NDT Instrument Based on FLASH Cartoon

FLASH. Mac versus PC. Pixels versus Vectors Two kinds of images are in the digital world: bitmaps and vectors:

WEB DESIGN COURSE CONTENT

Chapter 1. Introduction to ios Development. Objectives: Touch on the history of ios and the devices that support this operating system.

Android and OpenCV Tutorial

Additional details >>> HERE <<<

Creating a Custom Class in Xcode

Tutorial 9: Skeletal Animation

ios 9 Accessibility Switch Control - The Missing User Guide Updated 09/15/15

This documentation is made available before final release and is subject to change without notice and comes with no warranty express or implied.

DATA VISUALIZATION OF THE GRAPHICS PIPELINE: TRACKING STATE WITH THE STATEVIEWER

DESKTOP COMPUTER SKILLS

Getting Started with the Internet Communications Engine

Game Programming with DXFramework

Logging. Working with the POCO logging framework.

Portability Study of Android and ios

Programming Languages & Tools

USE OF HYPERVIDEO FOR TEACHING C/C++ Luiz-Alberto Vieira-Dias Andre Catoto-Dias

Features List Contents

User Recognition and Preference of App Icon Stylization Design on the Smartphone

Chapter 6 - The Scene Graph

CSET 3100 Advanced Website Design (3 semester credit hours) IT Required

Creating a 2D Game Engine for Android OS. Introduction

SBS ONLINE ADVERTISING GUIDELINES

COSC 111: Computer Programming I. Dr. Bowen Hui University of Bri>sh Columbia Okanagan

Cross-Platform Game Development Best practices learned from Marmalade, Unreal, Unity, etc.

6.088 Intro to C/C++ Day 4: Object-oriented programming in C++ Eunsuk Kang and Jean Yang

Freescale Semiconductor, I

AMPIFY YOUR BRAND ON SNAP MOBILE S MOBILE WEB NETWORK. May 2014

Research and Design of Universal and Open Software Development Platform for Digital Home

Optimization for DirectX9 Graphics. Ashu Rege

Developing Applications for ios

iphone Objective-C Exercises


ANIMATION a system for animation scene and contents creation, retrieval and display

Reach 4 million Unity developers

Equalizer. Parallel OpenGL Application Framework. Stefan Eilemann, Eyescale Software GmbH

MA-WA1920: Enterprise iphone and ipad Programming

SBS ONLINE ADVERTISING SPECS SBS JANUARY 2015

Transcription:

3 Multimedia Programming with C++ and Multimedia Frameworks 3.1 Multimedia Support by Languages and Frameworks 3.2 Introduction to C++ 3.3 SFML: Low-Level Multimedia/Game Framework for C++ 3.4 Cocos2d-x: High Level Game Engine for C++ Literature: cocos2d-x.org R. Engelbert: Cocos2d-x Beginner's Guide, 2nd ed., Packt Publishing 2015 LMU München, Sommer 2016 Prof. Hußmann: Multimedia-Programmierung Kapitel 3 Teil b, Folie 1

History and Status of Cocos2d(-x) February 2008, in "Los Cocos" (Argentina): Meeting of Python(!) game developers Ricardo Quesada and others create 2D game engine called "Cocos2d" Juli 2008: Apple AppStore for iphone, ios SDK Cocos2d rewritten in Objective-C ("cocos2d-iphone") Successful game apps for iphone based on Cocos2d (e.g. StickWars) Various ports and branches of the framework November 2010: Cocos2d-x by Zhe Wang (Xiamen, China) Based on C++ One codebase for many platforms Cocos2d-x is maintained by Chukong Technologies Inc. (Beijing) Latest version 3.10 (Jan 11, 2016) Claimed to be used by more than 400.000 developers worldwide LMU München, Sommer 2016 Prof. Hußmann: Multimedia-Programmierung Kapitel 3 Teil b, Folie 2

Basic Concepts: Layer, Scene, Node, Sprite Layer Layer, Sprite, DrawNode, Scene, : Subclasses of Node Vector Graphics (DrawNode) Sprite LMU München, Sommer 2016 Prof. Hußmann: Multimedia-Programmierung Kapitel 3 Teil b, Folie 3

Basic Concepts: Scene Graph scene layer drawnode sprite Scene is a special type of node which is used as root LMU München, Sommer 2016 Prof. Hußmann: Multimedia-Programmierung Kapitel 3 Teil b, Folie 4

QUIZ! What are the necessary statements (assignments) to create the tree structure indicated on the last slide? LMU München, Sommer 2016 Prof. Hußmann: Multimedia-Programmierung Kapitel 3 Teil b, Folie 5

Steps to Create a Basic Window Create a subclass of Layer (here: SlideShowScene) Define an initialization method init() Create a new Scene object scene Create a new object of the subclass of layer (SlideShowScene) Add it as a child to the scene object Hand it over to the engine for running Engine calls init() method for new object Initialization code Schedule functions and actions to be run LMU München, Sommer 2016 Prof. Hußmann: Multimedia-Programmierung Kapitel 3 Teil b, Folie 6

Creating a Standard Code Skeleton Using a Python(!)-implemented command for the terminal command line cocos new -l cpp -p slideshow0 -d /Users/hussmann/cocostest SlideShow0 Creates two classes (four files) with a standard structure Following code follows this given structure! LMU München, Sommer 2016 Prof. Hußmann: Multimedia-Programmierung Kapitel 3 Teil b, Folie 7

Code Skeleton for Slide Show class SlideShowScene : public cocos2d::layer { public: static Scene* createscene(); virtual bool init(); CREATE_FUNC(SlideShowScene); // implement "static create()" method }; void update(float dt); also calls "init()" Scene* SlideShowScene::createScene() { auto scene = Scene::create(); auto layer = SlideShowScene::create(); scene->addchild(layer); return scene; } bool SlideShowScene::init() { } SlideShowScene.hpp SlideShowScene.cpp LMU München, Sommer 2016 Prof. Hußmann: Multimedia-Programmierung Kapitel 3 Teil b, Folie 8

Concepts: AppDelegate, Director Class AppDelegate is home of the framework No need to change much in it! Contains the code: auto scene = SlideShowScene::createScene(); director->runwithscene(scene); Director object Keeps track of basic properties of application (e.g. size, view) Provides access to management of control flow: e.g. scheduler, event dispatcher, action manager AppDelegate.hpp AppDelegate.cpp LMU München, Sommer 2016 Prof. Hußmann: Multimedia-Programmierung Kapitel 3 Teil b, Folie 9

SlideShowScene: Prelude #include "SlideShowScene.hpp" #include <array> using namespace cocos2d; const int NUM_PICS = 4; //number of available slides const int INTERVAL = 4; //interval for slide change, in seconds const int BORDER = 30; //size of framing border in design pixels const Color4F bkgcolor = Color4F(255/255.0, 228/255.0, 95/255.0, 1); // Background color (yellowish) std::array<std::string, NUM_PICS> picfiles = {"frog.jpg","cows.jpg","elephant.jpg","tiger.jpg"}; // Traditional C style would be // std::string gpicfiles[num_pics{"frog.jpg","cows.jpg", "elephant.jpg","tiger.jpg"}; Size visiblesize; Size imagespritesize; float originximg; float originyimg; LMU München, Sommer 2016 Prof. Hußmann: Multimedia-Programmierung Kapitel 3 Teil b, Folie10

QUIZ! What is Color4F? What is the meaning of a value of 1.0 on fourth position? LMU München, Sommer 2016 Prof. Hußmann: Multimedia-Programmierung Kapitel 3 Teil b, Folie 11

SlideShowScene: Initialization (1) bool SlideShowScene::init() { // super init first if (!Layer::init() ) { return false; } // Initialize variables visiblesize = Director::getInstance()->getVisibleSize(); Vec2 origin = Director::getInstance()->getVisibleOrigin(); picindex = 0; // Create DrawNode for image frame rectangle imageframe = DrawNode::create(); this->addchild(imageframe); // Create sprite for images imagesprite = Sprite::create(); this->addchild(imagesprite); // Preload first image and determine image size imagesprite->settexture(picfiles[picindex]); imagespritesize = imagesprite->getcontentsize(); LMU München, Sommer 2016 Prof. Hußmann: Multimedia-Programmierung Kapitel 3 Teil b, Folie12

SlideShowScene: Initialization (2) // Position the sprite at the center of the screen originximg = origin.x + visiblesize.width/2; originyimg = origin.y + visiblesize.height/2; imagesprite->setposition(vec2(originximg, originyimg)); } // Draw the border, based on the coordinates and sizes we have computed imageframe->drawsolidrect( Vec2(originXImg-imageSpriteSize.width/2-BORDER, originyimg-imagespritesize.height/2-border), Vec2(originXImg+imageSpriteSize.width/2+BORDER, originyimg+imagespritesize.height/2+border),bkgcolor); // schedule the update function to be called every INTERVAL seconds this->schedule(schedule_selector(slideshowscene::update), INTERVAL); return true; Inversion of control! void SlideShowScene::update (float dt) { CCLOG("update called, dt = %f, picindex = %i", dt, picindex); // Increase picindex and set image according to picindex picindex = (picindex+1) % NUM_PICS; imagesprite->settexture(picfiles[picindex]); } LMU München, Sommer 2016 Prof. Hußmann: Multimedia-Programmierung Kapitel 3 Teil b, Folie13