Quantcast
Channel: Cocos Forums - Latest topics
Viewing all 17105 articles
Browse latest View live

Creator 2.4.0 Web-mobile build issue

$
0
0

After update cretor version from 2.3.1 to 2.4.0 web-mobile build could not find any project resources. Project works from editor preview.

loadScene: Can not load the scene 'db://assets/scenes/StartupScene.fire' because it was not in the build settings before playing.
```
![photo_2020-07-01_11-57-45|228x83](upload://79QypFEneiLMr7qWrI86AHH9HIR.jpeg)
Other builds like instant games or desktop mobile works.

2 posts - 1 participant

Read full topic


Fb instant game Build Failed

How to pass a vec4 array to shader uniform in version > 1.9?

$
0
0

in creator v1.9.3 i can pass an array to shader uniform without problems.
I do it like that:

in shader code

uniform vec4 test[2]

in js code

this._program.setUniformLocationWith4fv(“test”,[1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0])

or if i want to set individual elements of the array i should do that

this._program.setUniformLocationWith4f(“test[0]”, 1.0, 0.0, 0.0, 0.0)
this._program.setUniformLocationWith4f(“test[1]”, 0.0, 1.0, 0.0, 0.0)
this._program.setUniformLocationWith4f(“test[2]”, 0.0, 0.0, 1.0, 0.0)

It works correctly.

I don’t see ways to do it in v2.4. Where did i mistake and what should i do?

1 post - 1 participant

Read full topic

Can't import assets by drag and drop

$
0
0

I can’t import assets by dragging and dropping them in asset list. when i bring the mouse over there it turns red(the invalid cursor icon)

1 post - 1 participant

Read full topic

Tutorial: Generating a maze with DFS and BFS Algorithm Implementations

$
0
0

Generating a maze with DFS and BFS Algorithm Implementations

Inspiration

This tutorial is inspired by this GitHub repo.

Let’s take the above GitHub repository as inspiration and re-create this idea using Cocos Creator using TypeScript. The full project can be found in this GitHub repo.

Run animation

Demonstration of non-recursive random map generation process:

Demonstration of the pathfinding process of non-recursive random map generation:

Development environment

Labyrinth definition

What does the labyrinth look like? The definition of the maze is as follows:

  • Only one entrance, only one exit
  • Only one solution
  • The path is continuous
  • Draw on a square canvas: not other graphics, circles, etc.
  • Wall and path both occupy one cell

Tthe entrance is in the first column of the second row, and the exit is in the second last row:

Algorithms and data structures

The algorithm used to generate and find the maze:

The data structure involved is nn the Script/algorithm folder:

  • List: An interface definition for linear lists, queues and stacks
  • Queue: breadth-first traversal non-recursive implementation needs to be used
  • Stack: depth-first traversal non-recursive implementation needs to be used
  • RandomQueue: makes the generated map more random, but still a bit like BFS
  • RandomQueue2: an improved version of RandomQueue, the map is more random

Demo of the code

The demo of the code contains two parts:

  1. When the map has been generated, find the way from the entrance to find the exit.
  2. How to generate a map, dynamically demonstrate the map generation process in the presence of fog.

There are a total of 10 demos, which can be selected through the visualType attribute in the editor:

Support map size modification and map grid size modification:

1 post - 1 participant

Read full topic

Build Issue : Cannot read property 'devmode' of null

cc.Label can't display two font ttf same name in native

$
0
0

cc.Label can’t display two font ttf same name in native.
ex: UTM Avo Bold & UTM Avo Regular, font name is UTM Avo

UTM Avo.zip (33.8 KB)

1 post - 1 participant

Read full topic

How to get PhysicsSprite3D from its RigidBody

$
0
0

I made PhysicsSprite3Ds by using Physics3DRigidBodyDes like below.

Physics3DRigidBodyDes rbDes;
rbDes.mass = 0.0f;
rbDes.shape = Physics3DShape::createBox(Vec3(10.0f,10.0f,10.0f));
auto ps3d = PhysicsSprite3D::create("box.c3b", &rbDes);
ps3d->setTag(TAG_MAIN_CHARA);

Also I set collision callback to its rigidBody like below.

auto rigidBody = static_cast<Physics3DRigidBody*>(ps3d->getPhysicsObj());
rigidBody->setCollisionCallback([=](const Physics3DCollisionInfo &ci){
                if (!ci.collisionPointList.empty()){                    
                    auto rigidBodyA = static_cast<Physics3DRigidBody*>(ci.objA);
                    auto rigidBodyB = static_cast<Physics3DRigidBody*>(ci.objB);
                }
}

When collision is detected, I want to know what objects are collide.
So I want to get PhysicsSprite3D, because I set a Tag to know what it is.

But, I can get only rigidBody.

Are there any ways to get PhysicsSprite3D from its rigidBody.

Thank you.

1 post - 1 participant

Read full topic


Change button sprite-.

$
0
0
 Hello,

i would get the Url of the normalSprite from a Button, i use:

        console.log(this.node.normalSprite.nativeUrl); 
        console.log(this.node.getComponent(cc.Button).normalSprite.nativeUrl); 

but both of them give me : undefined
Where do i wrong?

Thank you :slight_smile:

2 posts - 2 participants

Read full topic

[iPhone] Can't unzip because i can't create folders

$
0
0

Hello,

i’m facing this issue in iOS specifically, it works fine in android.

here’s the code the I use to unzip zip files :

cocos2d::ZipFile zFile = cocos2d::ZipFile(zipLocation);
std::string fileName = zFile.getFirstFilename();
std::string file = fileName;
ssize_t filesize;
unsigned char* data = zFile.getFileData(fileName, &filesize);

std::string directoryName = cocos2d::FileUtils::getInstance()->getWritablePath();

if (!cocos2d::FileUtils::getInstance()->isDirectoryExist(directoryName))
{
	cocos2d::FileUtils::getInstance()->createDirectory(directoryName);
}

while (data != nullptr)
{
	std::string fullFileName = directoryName + file;
	//log("filename DIR : %s\n", fullFileName.c_str());
	if (fullFileName[fullFileName.size() - 1] == '/') {
		cocos2d::FileUtils::getInstance()->createDirectory(fullFileName);
		free(data);
		fileName = zFile.getNextFilename();
		file = fileName;
		data = zFile.getFileData(fileName, &filesize);
		continue;
	}

	FILE *fp = fopen(fullFileName.c_str(), "wb");

	if (fp)
	{
		fwrite(data, 1, filesize, fp);
		fclose(fp);
	}

	free(data);
	fileName = zFile.getNextFilename();
	file = fileName;

	data = zFile.getFileData(fileName, &filesize);
}

the problem comes from the fact the my zip has nested folders inside, the next code piece is responsible for that :
if (!cocos2d::FileUtils::getInstance()->isDirectoryExist(directoryName)){
cocos2d::FileUtils::getInstance()->createDirectory(directoryName);
}

but it’s unable to create directories, i’m getting : Fail to create directory

the code for createDirectory function :

bool FileUtilsApple::createDirectory(const std::string& path)
{
    CCASSERT(!path.empty(), "Invalid path");
    
    if (isDirectoryExist(path))
        return true;
    
    NSError* error;
    
    bool result = [s_fileManager createDirectoryAtPath:[NSString stringWithUTF8String:path.c_str()] withIntermediateDirectories:YES attributes:nil error:&error];
    
    if(!result && error != nil)
    {
        CCLOGERROR("Fail to create directory \"%s\": %s", path.c_str(), [error.localizedDescription UTF8String]);
    }
    
    return result;
}

I’m using an iphone 8 emulator.

1 post - 1 participant

Read full topic

Pixel Perfect Collision detection in 4.x

$
0
0

There are many posts on how to do pixel perfect collision detection of sprites in 2.x and 3.x.

Since 4.x uses metal instead of OpenGL, how will this change? Also since android doesn’t use metal, will we have to have to have a separate implementation for iOS and android?

1 post - 1 participant

Read full topic

The problem with the distribution of 3rd-party libs on win32

$
0
0

If you plan to release your game under win32, be careful with the 3rd-party libs, as they are compiled using c++ runtime dependencies of different versions of Visual Studio, such as msvcr110.dll, msvcr120.dll and one of dll’s even with msvcr120D.dll. For those who do not want to have problems with the distribution of their games in Win32, I have prepared a set of such libraries without any dependencies at all (actually i’m even prepared a static versions of those libs for myself, to be able to create standalone exe without any dll’s, but static linking probably could broke some foss licenses, so i’m not include static libs in this package), so you can compile your game in any version of Visual Studio you like, and distribute your game with only one version of mscvredist.exe:
Google drive 3rd-party-libs

1 post - 1 participant

Read full topic

Unexpected end of JSON input: Updating cocos creator 2.3.2 to v 2.4.0

$
0
0

I have updated cocos creator v2.3.2 to v2.4.0, While compiling our android project i found the following error :slightly_smiling:
main.js:104 Unexpected end of JSON input Error: Unexpected end of JSON input
at jsb-adapter/jsb-engine.js: 3145:17
at Object.readFile (jsb-adapter/jsb-engine.js:3116:19)
at readJson (jsb-adapter/jsb-engine.js:3137:13)
at parseJson (jsb-adapter/jsb-engine. js:3430:3)
at download (jsb-adapter/jsb-engine.js:3333:5)
at downloadJson (jsb-adapter/jsb-engine.js:3442:3)
at downloadBundle (jsb-adapter/jsb-engine .js:3464:3)
at a (src/cocos2d-jsb.655a2.js:11881:1)
at src/cocos2d-jsb.655a2.js:11891:1
at Object.retry (src/cocos2d-jsb.655a2 .js:13295:1)

When i debug this on chrome devTool i found that following json file was not loading,
build->jsb-links->assets -> internal ->config.97cbc.json
build->jsb-links->assets -> main -> config.ee485.json
build->jsb-links->assets -> resources ->config.9a721.json

I have deleted assets folder and made build for android again, But got same result. After more debugging i found cc.assetManager.loadBundle in main.js was unable to load these json because fs.getStringFromFile(assets/internal /config.97cbc. json) returns empty string and readJson method fail to parse.

Please let me know if there is an issue in new cc.assetManager, Looking for solution
Please check snaps attached

1 post - 1 participant

Read full topic

animation.addSpriteFrameWithFile error Uncaught TypeError: Cannot read property 'getContentScaleFactor' of undefined

$
0
0

i am trying to use animation, i dont have plist file, thus i have to add single images to the animation

    var animation = cc.Animation.create();

//add a sprite frame to this animation
animation.addSpriteFrameWithFile(blade_pics[0]); //here is the error

//create an animate with this animation
var action = cc.Animate.create(animation);

1 post - 1 participant

Read full topic

The Best Companies In America Build Mobile Games With Cocos


Edit box text isn't moving with edit box, when keyboard of phone is shown.

Cocos Showcase – 2020

$
0
0

If you wanted to see what the community in Cocos is building, then you’ll have to see this video. If you want to be in the next one, just add your game to our Game/Demo Showcase section and we’ll try to squeeze you in. Already have some amazing games to share for the next video as well.

Game List:

  • Imperial Saga Eclipse – Square Enix
  • The Strongest Demon Fighter – Tencent
  • Musical Poet – Shenzhen Wego Technology
  • More Aggressive Zombies – Hodor Games
  • Bridge Wars – Project R3D
  • Election Year Knockout – ExceptioNULL Games
  • Rolling Cat – KingWorks
  • Space Apocolypse – SPD Studio

1 post - 1 participant

Read full topic

Label initWithTTF issue with the Euro symbol

$
0
0

There is something wrong with the Label class of cocos2d-x v4 when using a TTF font and trying to print any string with the Euro or Pound symbol (example: 1,00€)
Nothing is printed. If I use the label with a system font it works. And it has nothing to do with the TTf used as the symbol is there and I tried with many fonts.
I haven’t got enough time to properly debug CCLabel.cpp but it looks the private UTF32 string is empty whenever the euro or pound symbol are present of the initial string.
Is this a known issue?

1 post - 1 participant

Read full topic

World Soccer Champs - new game

$
0
0

Hi everyone,
I wanted to present my new game created with cocos2d-x:

Available for iOS and Android:


2 posts - 2 participants

Read full topic

Error crash android app when create object sp.SkeletonAnimation

$
0
0

Hi everyone,
I have a error crash on android when i create any object sp.SkeletonAnimation();
I use cocos2d-x 3.17.2 with language JS and NDK r17c
my log error below:

Thanks!

2 posts - 1 participant

Read full topic

Viewing all 17105 articles
Browse latest View live


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>