Home Database Mysql Tutorial Cocos2dx屏幕匹配

Cocos2dx屏幕匹配

Jun 07, 2016 pm 03:09 PM
match Screen Ideas Horizontal screen Vertical screen

思路 1 )首先是横屏改为竖屏,因为 android 项目的 screenOrientation 默认为横屏; 2 )设置自适应屏。 【二】:横竖换屏 1 、 Cocos2d-x2.x 版 ,打开 main.cpp 文件 找到 eglView-setFrameSize(320,480); ,这里设置成你要的分辨率,用于开发。 Cocos2d-

思路

1)首先是横屏改为竖屏,因为android项目的screenOrientation默认为横屏;

2)设置自适应屏。

【二】:横竖换屏

1Cocos2d-x2.x,打开main.cpp文件

找到eglView->setFrameSize(320,480);,这里设置成你要的分辨率,用于开发。


Cocos2d-x3.x,则打开AppDelegate.cpp文件,在applicationDidFinishLaunching()里设置分辨率:glView->setFrameSizewidth,height;

2、生成android项目后修改AndroidManifest.xml文件

android:screenOrientation="landscape"横屏显示(默认)

android:screenOrientation="portrait"竖屏显示

 

【三】:自适应屏幕

这里算是个难点,应为android的开源,机型千奇百怪,我们没有办法去适应所有的屏幕,选择的方案也很多。

1、针对每个分辨率做一套方案(工程量太大);

2.cocos2dx2.0.4以后提供的缩放方案(相对1更适合);

使用方法:打开AppDelegate.cpp文件,找到:pDirector->setOpenGLView(CCEGLView::sharedOpenGLView());在下面添加:

CCEGLView::sharedOpenGLView()->setDesignResolutionSize(480,800, kResolutionNoBorder);

setDesignResolutionSize(设计宽,设计高,缩放方式);

该函数会自动按设计宽高和缩放方式适应手机屏幕。

缩放方式:

kResolutionExactFit       //自动缩放宽高全部显示(会变形)

kResolutionNoBorder    //不留黑边全屏展示(不变形,但是长的那边会被裁减)

kResolutionShowAll       //全部展示不裁剪(可能会留黑边)

【三】:适应相对坐标

我们坐标需要按照屏幕的实际大小来,所以也要使用相对坐标。

CCDirector::sharedDirector()->getVisibleSize();  //可视区域大小(用户手机分辨率)

CCDirector::sharedDirector()->getVisibleOrigin();//可视区域左下角坐标

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)
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Best Graphic Settings
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. How to Fix Audio if You Can't Hear Anyone
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
WWE 2K25: How To Unlock Everything In MyRise
3 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)

iPhone screenshots not working: How to fix it iPhone screenshots not working: How to fix it May 03, 2024 pm 09:16 PM

Screenshot feature not working on your iPhone? Taking a screenshot is very easy as you just need to hold down the Volume Up button and the Power button at the same time to grab your phone screen. However, there are other ways to capture frames on the device. Fix 1 – Using Assistive Touch Take a screenshot using the Assistive Touch feature. Step 1 – Go to your phone settings. Step 2 – Next, tap to open Accessibility settings. Step 3 – Open Touch settings. Step 4 – Next, open the Assistive Touch settings. Step 5 – Turn on Assistive Touch on your phone. Step 6 – Open “Customize Top Menu” to access it. Step 7 – Now you just need to link any of these functions to your screen capture. So click on the first

Does miniled screen hurt eyes? Does miniled screen hurt eyes? Feb 07, 2024 pm 03:48 PM

What many users are most concerned about is whether the miniLED screen will hurt the eyes. In fact, although the brightness of this screen can reach extremely high, it will not hurt the eyes and can still be used normally. Does the miniled screen hurt your eyes? Answer: It does not hurt your eyes. Although the brightness of the miniLED screen will be higher, it will not continue to maintain this brightness during daily use. It will only be displayed when the brightness needs to be increased, so it will not always maintain high brightness and hurt the eyes. This peak brightness is also for better Good presentation and expression. MiniLED screen introduction 1. MiniLED backlight display technology uses backlight, so the biggest difference from LCD is the backlight layer 2. Compared with LCD screen, the performance of miniLED will be higher.

How to adjust the color when the screen turns black and white. Detailed introduction: How to exit black and white mode on your mobile phone. How to adjust the color when the screen turns black and white. Detailed introduction: How to exit black and white mode on your mobile phone. Mar 21, 2024 pm 01:12 PM

When many friends are using their mobile phones, they suddenly find that the operation interface of the mobile phone has turned into "black and white" color. They don't know what causes it or how to solve it. This article uses Android mobile phones as an example to teach you how to make it work. The color of the mobile phone's operating interface returns to normal. 1. Set up the interface of the mobile phone and find the "gear-shaped" icon in the operation interface. As shown below: Click this icon to enter the phone’s settings interface. 2. Options The operating interface of the mobile phone has changed to black and white, which is related to the "Display" setting of the mobile phone. After entering the settings interface of the mobile phone, find the "Display and Theme" option in the drop-down menu, as shown below: Then click "Display and Theme" option to enter the details page. 3. After changing the screen color and entering the "Display and Theme" option, find the "

How to use Xiaomi Mi 14Ultra in landscape orientation? How to use Xiaomi Mi 14Ultra in landscape orientation? Feb 23, 2024 am 10:01 AM

Xiaomi Mi 14 Ultra is a relatively new model on the market. I believe that many consumers who want to change their mobile phones are more concerned about this phone. In addition to the conventional parameter configuration, the appearance design of this phone is also quite good. Of course, some people will also want to know how to use Xiaomi Mi 14Ultra horizontally? , the editor of this site will introduce the relevant content to you in detail below. Come and take a look together! How to use Xiaomi Mi 14Ultra in landscape orientation? Open the phone settings: First, find and open the settings icon on the home screen of Xiaomi 14, which is usually a gear-shaped icon. Enter display settings: In the settings menu, find and click the "Display" option to enter the display settings page. Turn on automatic screen rotation: In the display settings page, go to

How to Undo Delete from Home Screen in iPhone How to Undo Delete from Home Screen in iPhone Apr 17, 2024 pm 07:37 PM

Deleted something important from your home screen and trying to get it back? You can put app icons back on the screen in a variety of ways. We have discussed all the methods you can follow and put the app icon back on the home screen. How to Undo Remove from Home Screen in iPhone As we mentioned before, there are several ways to restore this change on iPhone. Method 1 – Replace App Icon in App Library You can place an app icon on your home screen directly from the App Library. Step 1 – Swipe sideways to find all apps in the app library. Step 2 – Find the app icon you deleted earlier. Step 3 – Simply drag the app icon from the main library to the correct location on the home screen. This is the application diagram

How to close the 'Do not cover the top of the screen' Detailed explanation: How to close the 'Do not cover the top of the screen' message that appears frequently on your phone How to close the 'Do not cover the top of the screen' Detailed explanation: How to close the 'Do not cover the top of the screen' message that appears frequently on your phone Mar 03, 2024 pm 01:31 PM

I believe many friends have encountered the problem that their mobile phones suddenly prompt: Do not cover the top of the screen. So why does the mobile phone suddenly appear like this? Let’s take a look together below. In fact, when this happens, something is blocking the distance sensor of the phone, so this prompt is received on the screen of the phone. So why did I suddenly receive such a prompt? In fact, it may be that you have accidentally turned on the [anti-accidental touch mode] on your phone, so this problem occurs. So how do we close it? In fact, the method is very simple. Let’s take a look at it together. Method 1: Directly follow the on-screen prompts to close using the shortcut key combination. Method 2: If the above method does not work, you can also open the phone’s [Settings]

Apple reveals iPhone 16 may have a larger display Apple reveals iPhone 16 may have a larger display Mar 22, 2024 pm 06:41 PM

Although it will be a long time before the release of the iPhone 16 series, there have been constant revelations about the appearance and configuration. According to Korean media SisaJournal, Apple plans to introduce new ultra-narrow bezel technology in the upcoming iPhone 16 series of mobile phones. The technology involves rolling internal copper wires into a more compact structure to reduce the bezel width of the phone's bottom display, allowing for a larger display. This innovative move aims to enhance the user experience, allowing users to enjoy a wider field of view and a more immersive entertainment experience. Apple has always been committed to continuously improving its product design and technology to bring more advanced functions and performance to users. The launch of the iPhone 16 series of mobile phones will further consolidate Apple’s leadership in smart phones. According to @SnapaDigital, Apple’s new

6000 mAh silicon negative battery! Xiaomi 15Pro upgrade leaked again 6000 mAh silicon negative battery! Xiaomi 15Pro upgrade leaked again Jul 24, 2024 pm 12:45 PM

According to news on July 23, blogger Digital Chat Station broke the news that the battery capacity of Xiaomi 15 Pro has been increased to 6000mAh and supports 90W wired flash charging. This will be the Pro model with the largest battery in Xiaomi’s digital series. Digital Chat Station previously revealed that the battery of Xiaomi 15Pro has ultra-high energy density and the silicon content is much higher than that of competing products. After silicon-based batteries are tested on a large scale in 2023, second-generation silicon anode batteries have been identified as the future development direction of the industry. This year will usher in the peak of direct competition. 1. The theoretical gram capacity of silicon can reach 4200mAh/g, which is more than 10 times the gram capacity of graphite (the theoretical gram capacity of graphite is 372mAh/g). For the negative electrode, the capacity when the lithium ion insertion amount reaches the maximum is the theoretical gram capacity, which means that under the same weight

See all articles