cocos2d | The googlecode address | Game Engine library
kandi X-RAY | cocos2d Summary
kandi X-RAY | cocos2d Summary
Some rules to keep in mind to reduce garbage collector:.
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
- Initializes a CCParticleSystem from a plist file
- Returns a decoded string
- Returns the number of bytes required to decode the source
- Load a texture reference
- Evaluate the geometry
- Find edge normal
- Finds the maximum separator between polygons
- Evaluate the contact body
- Compacts the polygon and touches the polygon and returns the result
- Updates the coordinates of a point
- Solve velocity constraints
- Calculate the items in rows for the layout
- Initial velocity constraints
- Initialize velocity constraints
- Calculate the point coordinates
- Compute the velocity constraints
- Updates the CCGrid
- Align the items in the grid
- Locate velocity constraints
- Draw this view
- Evaluate the contact
- Calculates the point coordinates
- Update the position
- Solve position constraints
- Solve the position constraints
- Unpack PVRData from the given ByteBuffer
cocos2d Key Features
cocos2d Examples and Code Snippets
Community Discussions
Trending Discussions on cocos2d
QUESTION
I have a file I'd like to parse to json. First item looks as follows:
...ANSWER
Answered 2021-Apr-29 at 12:21As @CharlesDuffy says, you can use ast.literal_eval()
.
You can read the content directly from your file:
QUESTION
I used resource of 2048x1536 for all iPad device. Resolution is not perfect in iPad Air(4th Gen) and iPadPro 11 inch.
In all other iPad display correct.
Tested in Cocos2dx v4.0
Here is my code:
...ANSWER
Answered 2020-Dec-13 at 18:32You are unsing ResolutionPolicy::NO_BORDER with that policy cropping can occur.
NO_BORDER: The entire application fills the specified area, without distortion but possibly with some cropping, while maintaining the original aspect ratio of the application.
When you use SHOW_ALL: The entire application is visible in the specified area without distortion while maintaining the original aspect ratio of the application. Borders can appear on two sides of the application.
QUESTION
In our game application for Android which is based on the game engine cocos2d-x, with most of the code being written in C++, we have a very strange and critical issue since Android 11:
When the native library gets loaded in onLoadNativeLibraries
it now suddenly takes 60+ seconds. Before Android 11, it all worked fine and it loaded in 0.2-3 seconds. Now when you start the game, you have a 60+ seconds gray screen.
We already figured out that JNI_OnLoad
gets called directly after the 60 second stall is over.
Here's the code of the onLoadNativeLibraries
function:
ANSWER
Answered 2020-Oct-29 at 18:06Short Answer:
It's a bug in Android 11 fixed by google but not deployed yet.
Meanwhile, if you don't care about calling static and thread_local variables destructors in your lib when program is exiting/library is unloaded, pass the flag -fno-c++-static-destructors
to the compiler. (see long answer for a more granular solution using clang annotations)
I used this flag on my project (not cocos2d) with no issue and lib is loading even faster than before.
Long Answer:
Unfortunately this is a performance regression introduced in android 11 (R) by the Google team. The issue is being tracked by google here.
To summarize, when System.loadLibrary()
is called, the system registers a destructor for each of the C++ global variables contained in the loaded library, using __cxa_atexit()
Since Android 11 (R), the implementation of this function in android has changed:
- In Q, __cxa_atexit uses a linked list of chunks, and calls mprotect twice on the single chunk to be modified.
- In R, __cxa_atexit calls mprotect twice on a single contiguous array of handlers. Each array entry is 2 pointers.
This change regressed the performance drastically when they are many C++ global variables which seems to be the case in cocos2d so libraries.
Google has already implemented a fix https://android-review.googlesource.com/c/platform/bionic/+/1464716 but as stated in the issue:
this won't be in Android 11 until the March QPR at the earliest, and since this isn't a security issue it won't be mandatory for OEMs to actually take that patch.
Google Team suggests also some workarounds at the app level by removing or skipping the destructors on global variables:
- For a particular global variable, the [[clang::no_destroy]] attribute skips the destructor call.
- Pass -fno-c++-static-destructors to the compiler to skip the destructors for all static variables. This flag also skips destructors for thread_local variables. If there are thread_local variables with important destructors, those can be annotated with [[clang::always_destroy]] to override the compiler flag.
- Pass -Wexit-time-destructors to the compiler to make it warn on every instance of an exit-time destructor, to highlight where the __cxa_atexit registrations are coming from.
QUESTION
Cocos2d-x v4.0 crashing in all iPhone Simulator. In device no crash
...ANSWER
Answered 2020-Nov-20 at 22:25With that little info we can't help much. But if I try to interpret the posted image corretly you receive a "EXC_BAD_ACCESS" Exception.
This means more or less that you access a freed memory region or in general you try dereference a pointer pointing to an invalid memory address.
The only argument which could cause such an error is source.c_str()
.
So you should check the code path of source
.
In release builds you don't see always "access-after-free" because memory is not immediately released to the OS (which triggers such errors) it is just marked as "free" to allow faster allocations.
QUESTION
I'm porting a qt project that compiles on a MacOS to Windows. I've managed to more or less fix all of the compiler errors, but I'm now met with this:
...ANSWER
Answered 2020-Aug-14 at 11:33It would seem that LIBAPP
is indeed unset. Why that is the case, I don't know. It's dependency, using the same kit and compiler has it set just fine.
Solution I employed is to just set LIBAPP
to, in my case, llvm-lib /NOLOGO
.
I absolutely hate everything about this.
QUESTION
The image can be with transparent pixels. How do I get the minimum size of a rectangle that fits this image without transparent pixels? I want to get something like this:
...ANSWER
Answered 2020-Aug-10 at 06:02This is just a basic example. You will have to customize it.
QUESTION
I have been given a task to make a qt project originally created on Mac run on Windows. It needs to use MinGW (g++ and gcc) for compilation.
I had problems with _WIN32
and _WINDOWS
not being defined when trying to build the project (although it says in settings that they were), so I just hardcoded that bit for the time being.
I also had to add GL\glew.h
and ft2build.h
and whole freetype library to have all the required files for win32 version of cocos2d.
However, Qt Creator is now complaining that I'm defining dllimport
static fields for most of Cocos2d objects. There are also thousands of warnings that bunch of objects are being redeclared without dllimport
attribute. I haven't touched Cocos2d files (other than the platform one where I forced it to use win32).
What am I doing wrong (other than the hardcoding bit)?
...ANSWER
Answered 2020-Jul-31 at 09:50I had to define _WIN32
and _WINDOWS
in the project menu of the QtCreator as additional arguments for make to avoid the hardcoding. I also had to define CC_STATIC
to prevent Cocos2d to insert the dllimport
or dllexport
before each of the functions. The arguments I added were:
QUESTION
I cannot confirm whether this has been since a newer iOS version (perhaps 11 onwards) but the hardware volume buttons do not respond whilst using an app I am updating at present.
It uses SimpleAudioEngine
and whilst I have looked at some other projects I have that use Cocos2d-x, I have tried to use the SimpleAudioEngine
source from there, with zero success.
The version of cocos2d-x is v2.1.1
In my HelloWorldScene.cpp
I am calling
ANSWER
Answered 2020-May-25 at 18:53In most of my apps i use the same syntax and it is working using cocos2d-x version 3.17.2.
QUESTION
Which EventDispatcher to use in cocos2d ? Node::EventDispatcher or Director::EventDispatcher ? After referencing the official documentation of both Director class and Node class Director Class Reference Cocos2d-x Node Class Reference Cocos2d-x I am a bit confused about, what is the difference between using
...ANSWER
Answered 2020-Apr-29 at 18:05Both are same. this->getEventDispatcher() calls CCNode's getEventDispatcher() function. It returns _eventDispatcher.
QUESTION
I'm using cocos 3.17 on Xcode 11 on Mac. These are my fragment and vertex shaders.
myShader.frag
...ANSWER
Answered 2020-Apr-29 at 13:46After some troubles, I found the solution. A GLSL shader that does not have a #version directive at the top is assumed to be 1.10, but I really need version 1.2. So, I need to add '#version 120\n' as a compileTimeHeader string in the initialization:
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install cocos2d
You can use cocos2d like any standard Java library. Please include the the jar files in your classpath. You can also use any IDE and you can run and debug the cocos2d component as you would do with any other Java program. Best practice is to use a build tool that supports dependency management such as Maven or Gradle. For Maven installation, please refer maven.apache.org. For Gradle installation, please refer gradle.org .
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page