Tag Archives: cocos2d

‘pre-mature EOF‘ : syntax error syntax error [How to Solve]

1. Version

cocos3.4

2. Defects of stringify

Customized a fragment shader, mimicking the official method, using STRINGIFY to convert the code to strings. Run it and report an error

cocos2d: ERROR: Failed to compile shader: uniform mat4 CC_PMatrix;
uniform mat4 CC_MVMatrix; uniform mat4 CC_MVPMatrix; uniform mat3
CC_NormalMatrix; uniform vec4 CC_Time; uniform vec4 CC_SinTime;
uniform vec4 CC_CosTime; uniform vec4 CC_Random01; uniform sampler2D
CC_Texture0; uniform sampler2D CC_Texture1; uniform sampler2D
CC_Texture2; uniform sampler2D CC_Texture3; //CC INCLUDES END

varying vec4 v_fragmentColor; varying vec2 v_texCoord; uniform float
outlineSize; uniform vec3 outlineColor; uniform vec2 textureSize;
uniform vec3 foregroundColor; const float cosArray[12] = { 1 cocos2d:
ERROR: 0:? : ‘pre-mature EOF’ : syntax error syntax error

The following is the reason for my guess error:
the problem lies in the initialization statement of floating-point array. Stringify is a macro definition function, which is defined as:

#define STRINGIFY(A) #A

Here a # syntax of macro definition is used to convert A into a string. When A contains a ‘,’ character, A is truncated and incomplete. For example, STRINGIFY (int a,b) expects the string to be “int a,b”, but in fact it will be “int a”. In fact, STRINGIFY is expanded with two arguments, the first being int a and the second being b.

3. Solutions

3.1. Add ()

Call STRINGIFY with brackets in the argument: STRINGIFY((AB)). However, the string obtained this way will also be bracketed and needs to be unbracketed, which is more troublesome

3.2. Write directly as a string

For example:

GLchar my_vert[] = "\
attribute vec4 a_position;\n\
attribute vec2 a_texCoord;\n\
attribute vec4 a_color;\n\
\n\
#ifdef GL_ES    \n\
varying lowp vec4 v_fragmentColor;   \n\
varying mediump vec2 v_texCoord;   \n\
#else  \n\
varying vec4 v_fragmentColor;\n\
varying vec2 v_texCoord;  \n\
#endif  \n\
\n\
void main()  \n\
{  \n\
	gl_Position = CC_PMatrix * a_position;  \n\
	v_fragmentColor = a_color;  \n\
	v_texCoord = a_texCoord;  \n\
}";

It’s also troublesome. You need to add \n\ to each line.

3.3. Write the code into a file

For example:

#ifdef GL_ES
precision lowp float;
#endif

varying vec4 v_fragmentColor;
varying vec2 v_texCoord;

void main()
{
	float ff=1;
	gl_FragColor = texture2D(CC_Texture0, v_texCoord);
	float f=(gl_FragColor.r+gl_FragColor.g+gl_FragColor.b)/3.0f; 
	gl_FragColor=vec4(f,f,f,gl_FragColor.a);
}

Save the above code as ccShader_PositionTextureColor_noMVP_Gray.fsh file. Then use

std::string fragmentSource=FileUtils::getInstance()->getStringFromFile(FileUtils::getInstance()->fullPathForFilename("shaders/ccShader_PositionTextureColor_noMVP_Gray.fsh"));

Direct reading.

[Solved] Git Clone Error: error:1407742E:SSL routines:SSL23_GET_SERVER_HELLO:tlsv1 alert protocol version

1. Error description

An error is reported when using the GIT command to clone a git warehouse, as shown below:

C:\Users\000>git clone https://hub.fastgit.org/githubhaohao/NDK_OpenGLES_3_0.git
Cloning into 'NDK_OpenGLES_3_0'...
fatal: unable to access 'https://hub.fastgit.org/githubhaohao/NDK_OpenGLES_3_0.git/': error:1407742E:SSL routines:SSL23_GET_SERVER_HELLO:tlsv1 alert protocol version

2. Analysis error

2.1 view http.sslversion version

The http.sslversion version is tlsv1.0 as follows:

C:\Users\000>git config http.sslVersion
tlsv1.0


Weak cryptographic standards removal notice

We will then restore support for the deprecated algorithms and provide a two week grace period for these systems to upgrade their libraries before we disable support for the deprecated algorithms permanently on February 22, 2018.

As noted above, the vast majority of traffic should be unaffected by this change. However, there are a few remaining clients that we anticipate will be affected. Fortunately, the majority of clients can be updated to work with TLSv1.2.


In a word, upgrade to the versionTLSv1.2.

3. Solution
Add the following two configuration

C:\Users\000>git config --global --unset http.sslVersion

C:\Users\000>git config --global --add http.sslVersion tlsv1.2

C:\Users\000>git config --global --add http.sslbackend openssl

Then restart the GIT clone project, as shown below:

How to Solve cocos2dx msb3073 Error

Solve cocos2dx 3.17 error msb3073:: vcend “has exited, the code is 9009 and an error is reported

For example, if the dill function appears, and the msb3073 code is 9009 or 4, the error
and the libcurl file cannot be connected appear at the same time, or the error
msb3073 code is 9009, the command xcopy/Y/Q and if not exist will be prompted (your project path)
the solution is as follows (try one by one) :
1. Change the Cocos environment path from Chinese to English or the project path from Chinese to all citations
2. Confirm that your environment variables are set correctly and that pyhton and cocos environment variables are
3. If none of the above methods can be solved, your problem should be the same as me. If you reinstall the system or newly install the system, in the path of the environment variable Adding C:\windows\system32 should be able to solve the problem, because you may have deleted the environment variable path by mistake, resulting in file replication failure. Add the following files in sequence:% systemroot%\system32;% systemroot%;% systemroot%\system32\WBEM;% systemroot%\system32\windowspowershell\v1.0;
as shown in the figure

How to Solve Cocos creator label text is too many error

Cocos creator label text is too many and an error is reported

There are thousands of lines of legal entries such as user agreements and privacy terms

That’s what it said

let labelNode = new Node('labelNode')
let label = labelNode.addComponent(Label)
label.cacheMode = Label.CacheMode.CHAR
label.string = '....' 

In this way, it can be loaded at once, and the protocol can be closed. When loading other protocols, an error of too long font size will be reported

After a long toss, the characters here are too long to keep the cache. Change the cachemode to none, but even none can’t load so much. Just write in several paragraphs

let a1 = ""
let a2 = ""
let a3 = ""
this.addLabel('a1', 0, a1)
this.addLabel('a2', -2000, a2)
this.addLabel('a3', -4000, a3)
addLabel(name:string, y: number, text:string){
	let labelNode = new Node(name)
	labelNode.layer = Layers.BitMask.UI_2D
	labelNode.setPosition(0, y)
	let label = labelNode.addComponent(Label)
	label.cacheMode = Label.CacheMode.NONE
	label.string = text
	this.node.addChild(labelNode)
}

Cmake compile cocos2d-x error [How to Solve]

Enter at the terminal:

cocos run --proj-dir .. -p mac

The error information is as follows:

-- The C compiler identification is unknown
-- The CXX compiler identification is unknown
CMake Error at CMakeLists.txt:30 (project):
  No CMAKE_C_COMPILER could be found.



CMake Error at CMakeLists.txt:30 (project):
  No CMAKE_CXX_COMPILER could be found.



-- Configuring incomplete, errors occurred!
See also "/Users/roy/Desktop/workspace/CocosProject/MyGame/mac-build/CMakeFiles/CMakeOutput.log".
See also "/Users/roy/Desktop/workspace/CocosProject/MyGame/mac-build/CMakeFiles/CMakeError.log".

Solution:

sudo xcode-select --reset

Xcode12 error in compiling cocos2d [How to Solve]

Using xcode12 to build the cocos2d 3.17 project has the following similar problems:

the linked framework is missing one or more architectures required by this target arm64

The reason: because V8 does not support 32-bit CPU, that is, it does not support armv7. If you do not need to support 32-bit devices, you can directly remove the compilation of armv7

Amend as follows:

 

  Basically, the above four modifications can solve the project running in the debug mode. It has not been tried on the real machine for the time being. It should also directly modify the configuration in the release.

There will be some minor problems after modifying the above:

1.Argument value 10880 is outside the valid range [0, 255]

Amend as follows:

Need to

#define BT_ SHUFFLE(x,y,z,w) ((w)<& lt; 6 | (z)<& lt; 4 | (y)<& lt; 2 | (x))

Change to

#define BT_ SHUFFLE(x, y, z, w) (((w) <& lt; 6 | (z) <& lt; 4 | (y) <& lt; 2 | (x)) & 0xff)

2.The application’s Info.plist does not contain CFBundleShortVersionString.

Modify as follows: add cfbundleshortversion in info.plist