• Keine Ergebnisse gefunden

Multimedia-Programmierung Übung 4

N/A
N/A
Protected

Academic year: 2022

Aktie "Multimedia-Programmierung Übung 4"

Copied!
31
0
0

Wird geladen.... (Jetzt Volltext ansehen)

Volltext

(1)

Multimedia-Programmierung Übung 4

Ludwig-Maximilians-Universität München

Sommersemester 2018

(2)

Today

(3)

Overview – Alternative Engines

https://libgdx.badlogicgames.com/

https://unity3d.com/

SpriteKit for Apple platforms:

https://developer.apple.com/spritekit/

http://www.pygame.org/hifi.html

https://coronalabs.com/

http://www.yoyogames.com/

And many more…

(4)

What is Cocos and where does it come from?

Cocos2d-x is an open source, cross- platform game engine

Cocos is a platform to create games,

including Cocos2d-x, editors, SDK

integration

(5)

The Platform

http://www.cocos2d-x.org/docs/cocos/cocos/index.html

(6)

What is a game engine?

• A piece of software providing common functionality that all games need

• Important components:

• Cross-platform: develop once and deploy to

http://www.cocos2d-x.org/docs/programmers-guide/1/index.html

• Renderer

• 2d/3d graphics

• Collision detection

• Physics engine

• Animations

• Sound

(7)

Cocos street credibility!?

Badland Dragon City

Castle Clash Big Fish Casino

Many more: http://www.cocos2d-x.org/games

(8)

Prerequisites

• A working C++ compiler

• Windows: Visual Studio Express

• Mac OS: Xcode

• Python 2.7.x (version matters!)

• Optional: Android SDK

• And of course: cocos2d-x

http://www.cocos2d-x.org/docs/static-pages/installation.html

http://www.cocos2d-x.org/docs/installation/A/index.html

(9)

Installation and Use of Cocos

http://www.cocos2d-x.org/products

(10)

Installation via Command Line

• Download cocos2d.zip from

http://www.cocos2d-x.org/download

• Unzip and cd into that folder

• Use “python setup.py“ to set environment variables

• Skip all SDK setups with Enter

• Restart concole

(11)

Setup Visual Studio 2017

Check the following tools in the Visual Installer

(12)

Core concepts:

Director, Scene, Node, Sprite, Action

Cocos2d-x basics

(13)

• Singleton object, always accessible

• Used to control game flow

Cocos2d-x basics: Director

(14)

• Typical scenes: main menu, levels, game over

• Renders graphical scene objects

Cocos2d-x basics: Scene

Game example: Banana Kong

(15)

• Tree structure

• Arranges graphical scene objects in parent- child relationships

• Contains node objects

Cocos2d-x basics: Scenegraph

Nodes in this scene?

(16)

• 2D images that can be moved and transformed

• Example: main character, enemies etc…

• Configurable properties: position, rotation, scale, opacity, color

Cocos2d-x basics: Sprites

(17)

• Action objects make a Node perform a change to its properties over time

• Example: move a sprite from one position to another over a span of time

• Example Actions: MoveBy, Rotate, Scale

• Applicable to all Node objects

• Also available: sequences and spawns of actions

Cocos2d-x basics: Actions

(18)

Using Cocos GUI:

http://www.cocos2d-

x.org/docs/cocos/cocos/index.html#using-cocos Using the command line tool (only for

Python 2.7):

http://www.cocos2d-

x.org/docs/editors_and_tools/cocosCLTool/inde

Building a new Project

(19)

Building a new Project using the GUI

(20)

Building a new Project using the Terminal

• Check python --version

• Version 2.7.x use command:

cocos new –p ProjectName –d PathToDirectory

• Version 3.6.x need to install Python 2.7 and use console tool from cocos folder

cd cocos2d-x-3.15\tools\cocos2d-console\bin

• Windows: py -2.7 cocos.py new ...

• Mac: python2 cocos.py new ...

(21)

Result

(22)

Result

IDE projects (Visual Studio, Xcode etc.)

Your C++ files

Images, Sounds, etc…

(23)

Hello World – Auto-generated App

(24)

Hello World – HelloWorldScene.cpp

Creating the scene

(25)

Hello World – AppDelegate.cpp

Using the director

to run the game

with the scene

(26)

Today’s Project: A small game!

(27)

Airhockey-Game

3 Classes:

• AppDelegate

to run the Game

• GameLayer

includes the game function

• GameSprite

for the movable objects (players + ball)

Focus on GameLayer

(28)

Airhockey-Game: GameLayer

Create init () which includes

• 2 player and 1 ball

• EventListener

(29)

Airhockey-Game: GameLayer (2)

Create update()

(30)

Airhockey-Game: GameLayer (3)

Define Eventlistener

• onTouchBegan

• onTouchMoved

• onTouchEnded

(31)

Links

http://www.cocos2d-x.org/wiki/External_Tutorials http://wizardfu.com/book/cocos2d-x/tutorial/

http://www.gamefromscratch.com/page/Cocos2d-x-CPP-

Game-Programming-Tutorial-Series.aspx

Referenzen

ÄHNLICHE DOKUMENTE

Sergio BALDI, Università degli Studi di Napoli Iwona KRASKA-SZLENK, University of Warsaw Marcin KRAWCZUK, University of Warsaw Kamil KURASZKIEWICZ, University of Warsaw..

MICHAŁ TYMOWSKI (University of Warsaw) HAFIZU MIKO YAKASAI (Bayero University, Kano) ANDRZEJ ZABORSKI (Jagiellonian University) JERZY ZDANOWSKI (Polish Academy of

The purpose of this journal is to ensure the early publication of monographs and research work (source and analysis: bibliographies, maps, lexicographic studies, articles)

auto rotateTo = RotateTo::create(2.0f, 60.0f); // Rotates to a specific angle over 2 seconds mySprite->runAction(rotateTo);. auto rotateBy = RotateBy::create(2.0f, -60.0f);

– groups() returns a list of groups the sprite belongs to – alive() tests whether the sprite belongs to any groups...

• Rect or radius based collision detection is fast but imprecise..

• Create an Event Listener in the cpp file and map each Touch Event to a function handler. ● Create a separate function handler for each

– SMIL 2.0 Language Profile (SMIL Profile): gesamter Sprachumfang – SMIL 2.0 Basic Language Profile (SMIL Basic): speziell für mobile. Endgeräte