Home Database Mysql Tutorial cocos2d学习

cocos2d学习

Jun 07, 2016 pm 03:43 PM
main create study game structure

游戏的主要逻辑和结构:创建游戏场景,在场景上添加一个或者多个层,在指定层上添加精灵、菜单、文字,为精灵和文字执行某个动作(移动),检测玩家触屏事件,开启任务调度执行碰撞检测和更新数据,通过导演类管理和切换场景等等。 (1)场景(CCScene) 就是游戏

游戏的主要逻辑和结构:创建游戏场景,在场景上添加一个或者多个层,在指定层上添加精灵、菜单、文字,为精灵和文字执行某个动作(移动),检测玩家触屏事件,开启任务调度执行碰撞检测和更新数据,通过导演类管理和切换场景等等。

(1)场景(CCScene)

就是游戏的关卡,也可以表示一个界面。你可以只创建一个场景也可以创建多个场景。它是构成游戏的画面,一般是先绘制一个场景,然后在场景中叠加或组合一个或者多个层。

(2)层(CCLayer)

我们的游戏内容一般是显示在层上的,通过叠加多个层来实现不同的效果。可以设置层的叠加顺序,处理事件响应机制。cocos2d-x提供了一些公用层:菜单层,颜色层等。每一层可以包含各式各样的内容要素:文本、精灵、地图等。

(3)精灵(CCSprite)

精灵是整个游戏中的核心对象,如:敌机、英雄、子弹等,精灵就是一些可以不断变化的图片,而所谓游戏,就是玩家操作一个或多个精灵与其他玩家或者系统控制的精灵进行互动。

(4)导演(CCDirector)

cocos2d-x中导演类CCDirector是个单例,这里主要用来管理和显示场景的,还提供一些常用的属性,如获取窗口的宽高等。

(5)任务调度机制

通常在游戏中需要实现一个计时器,以指定的时间间隔不停的调用某个指定的回调函数,来改变屏幕的显示或者进行数据处理。cocos2d-x提供了内置的任务调度机制,即CCNode的schedule成员函数。如

this->schedule(schedule_selector(GameScene::update), 1.0f);

每隔1秒执行一次update函数,如果不指定时间则每一帧执行一次。

(6)动作(CCAction)

就是精灵拥有的动作,如:子弹移动、飞机飞行等。


Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
2 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Repo: How To Revive Teammates
4 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Hello Kitty Island Adventure: How To Get Giant Seeds
4 weeks ago By 尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Nvgpucomp64.dll causes Windows PC games to crash; Nvgpucomp64.dll causes Windows PC games to crash; Mar 26, 2024 am 08:20 AM

If Nvgpucomp64.dll is causing your game to crash frequently, the solutions provided here may help you. This problem is usually caused by outdated or corrupted graphics card drivers, corrupted game files, etc. Fixing these issues can help you deal with game crashes. The Nvgpucomp64.dll file is associated with NVIDIA graphics cards. When this file crashes, your game will crash too. This usually happens in games like LordsoftheFallen, LiesofP, RocketLeague, and ApexLegends. Nvgpucomp64.dll crashes games on Windows PC if N

Introduction to how to download and install the superpeople game Introduction to how to download and install the superpeople game Mar 30, 2024 pm 04:01 PM

The superpeople game can be downloaded through the steam client. The size of this game is about 28G. It usually takes one and a half hours to download and install. Here is a specific download and installation tutorial for you! New method to apply for global closed testing 1) Search for "SUPERPEOPLE" in the Steam store (steam client download) 2) Click "Request access to SUPERPEOPLE closed testing" at the bottom of the "SUPERPEOPLE" store page 3) After clicking the request access button, The "SUPERPEOPLECBT" game can be confirmed in the Steam library 4) Click the install button in "SUPERPEOPLECBT" and download

ASUS releases BIOS update to improve gaming stability on Intel's 13th/14th generation processors ASUS releases BIOS update to improve gaming stability on Intel's 13th/14th generation processors Apr 20, 2024 pm 05:01 PM

According to news from this site on April 20, ASUS recently released a BIOS update, which improves instability such as crashes when running games on Intel's 13th/14th generation processors. This site previously reported that players reported problems including that when running the PC demo version of Bandai Namco's fighting game "Tekken 8", even if the computer has sufficient memory and video memory, the system will crash and prompt an error message indicating insufficient memory. Similar crashing issues have also appeared in many games such as "Battlefield 2042", "Remnant 2", "Fortnite", "Lord of the Fallen", "Hogwarts Legacy" and "The Finals". RAD published a long article in February this year, explaining that the game crash problem is a combination of BIOS settings, high clock frequency and high power consumption of Intel processors.

Paving the way for PS5 Pro, the 'No Man's Sky' update code 'surprised' the game console development code name 'Trinity' and image quality configuration file Paving the way for PS5 Pro, the 'No Man's Sky' update code 'surprised' the game console development code name 'Trinity' and image quality configuration file Jul 22, 2024 pm 01:10 PM

According to news from this site on July 22, foreign media twistedvoxel discovered the rumored PS5 development codename "Trinity" and related image quality configuration files in the latest "World Part 1" update code of "No Man's Sky", which proves that Sony is expected to The PS5Pro model was recently launched. Although "No Man's Sky" has enhanced the graphics performance of the game in recent updates, many players still believe that this may be HelloGames paving the way for new models in advance. According to the latest graphics presets, under PS5 Pro The game's dynamic resolution scaling has been increased from 0.6 to 0.8, which means the game has a higher average resolution and some graphical details are upgraded from "High" to "Ultra" levels, but since each game

How to disable input method when playing games in Win11 How to disable input method when playing games in Win11 Mar 15, 2024 pm 02:40 PM

Recently, some friends have reported that they often press the input method when playing games, which greatly affects the gaming experience. Here I will give you a detailed introduction to the method of disabling the input method when playing games in Win11. Anyone who needs it Friends can come and take a look. Disabling method: 1. Right-click the input method icon in the taskbar in the lower right corner and select "Language Preferences" in the list. 2. After entering the new interface, click the "Add preferred language" option. 3. In the pop-up window, select "English (United States)". 4. Click "Next" again. 5. Then choose whether to install some options according to your needs. 6. Then click "Install" and wait for the installation to complete. 7. Then click on the input method status bar in the lower right corner and select the "English (

Explanation on how to turn on the microphone permission for Apple mobile phone games Explanation on how to turn on the microphone permission for Apple mobile phone games Mar 22, 2024 pm 05:56 PM

1. Click on [Privacy] in the phone settings. 2. Click the [Microphone] option. 3. Turn on the switch on the right side of the game application that requires setting microphone permissions.

How to solve the problem that the taskbar keeps showing up when playing games in WIN10_How to solve the problem that the taskbar keeps showing up when playing games in WIN10 How to solve the problem that the taskbar keeps showing up when playing games in WIN10_How to solve the problem that the taskbar keeps showing up when playing games in WIN10 Mar 28, 2024 am 08:36 AM

1. Right-click on a blank space on the taskbar, then find Properties and click on it. 2. Here you can see that the system default setting is not to automatically hide the taskbar. 3. Click to check, then OK to save changes. 4. When we return to our desktop, we can see that the taskbar is automatically hidden. If we move the mouse cursor to the bottom, it will be displayed again.

PlayerUnknown's Battlegrounds FPS optimization settings, Chicken PUBG game frame rate optimization PlayerUnknown's Battlegrounds FPS optimization settings, Chicken PUBG game frame rate optimization Jun 19, 2024 am 10:35 AM

Optimize the frame rate of the PlayerUnknown's Battlegrounds game to improve the smoothness and performance of the game. Method: Update the graphics card driver: Make sure you have the latest graphics card driver installed on your computer. This helps optimize game performance and fix possible compatibility issues. Lower game settings: Adjust the graphics settings in the game to a lower level, such as reducing resolution, reducing special effects and shadows, etc. This takes the load off your computer and increases your frame rate. Close unnecessary background programs: While the game is running, close other unnecessary background programs and processes to free up system resources and improve game performance. Clear hard drive space: Make sure your hard drive has enough free space. Delete unnecessary files and programs, clean temporary files and Recycle Bin, etc. Turn off vertical sync (V-Sync): in game

See all articles