Quantcast
Channel: cocos2d-x - Cocos Forums
Viewing all 2748 articles
Browse latest View live

JS: :0:too much recursion

$
0
0

@11175 wrote:

Hi,

I'm experiencing the same issue but i think the context is different and I don't know what I can do.

I have an android application with 2 activities A and B

A is a home app with menu, preference, etc and it's in android native ui

B is a cocos2dx-js activity and this is launch from the activity A.

In the ui thread of B there is an android ui button that allow to switch back to A to change some preferences before coming back to B.

When the application switch between activities : A -> B -> A -> B, the cocos2d-x context seems the same but i've got the "too much recursion" issue.

Any ideas to solve this ?
note:use cocos2dx-js version 3.14.1

Posts: 1

Participants: 1

Read full topic


EventListener Graph priority and inheritance

$
0
0

@xabierotano wrote:

Hi there,
I have a LayerB that inherits from LayerA.
Inside LayerA they are added some nodes , imagine SpriteX and SpriteZ
Inside LayerB , SpriteW is added.
Each sprites have their own eventGraphPriorityListeners.

The code is something like this
Inside B

LayerB::init(){
   if(! LayerA::init() ){
        return false;
   }
  SpriteW::create();
  addchild(SpriteW,1);
}

Inside A:

LayerA::init(){
   SpriteX::create();
   addchild(SpriteX,10);
   SpriteZ::create();
   addchild(SpriteZ,10);
}

I am seeing that sometimes, the event listener associated to LayerA are not called since they are being ate by SpriteW.
How thats possible?
I am doing something wrong?

Posts: 1

Participants: 1

Read full topic

Can't compile in Android after update

$
0
0

@jmclaveria wrote:

I have updated Android SDK to SDK version 24. Gradle syncs fine in Android Studio but using the command "cocos compile -m release -p android --android-studio" fails with errors:


The "android" command is deprecated.
For manual SDK, AVD, and project management, please use Android Studio.
For command-line tools, use tools/bin/sdkmanager and tools/bin/avdmanager


Invalid or unsupported command "update project -t android-15 -p /Users/jmclaveria/Documents/XCode/RamboatX/proj.android-studio/app"

Supported commands are:
android list target
android list avd
android list device
android create avd
android move avd
android delete avd
android list sdk
android update sdk
Error running command, return code: 2.

Have tried to download the new tools as said in this thread, but it didn't work.

How can I compile my project with the command line?

Posts: 3

Participants: 2

Read full topic

PreBuilt Libraries, Android Studio & NDK_MODULE_PATH

$
0
0

@zx12a1 wrote:

More idiotic questions and intractable problems.

I am using @piotrros example (http://discuss.cocos2d-x.org/t/how-to-link-prebuilt-cocos2d-x-c-library-to-android-studio-project/32949/11?u=piotrros) to demonstrate using prebuilts with Android Studio. My cocos compile for studio is failing and it is because my NDK_MODULE_PATH is NOT getting set.

Has anyone any ideas where my problem might be??

My errors look like:
Building native...
NDK build mode: debug
running: '/Users/NF/SDK/android-ndk-r13b/ndk-build -C /Users/NF/MobDev/Cocos/ProjectName/proj.android-studio/app -j2 NDK_MODULE_PATH=/Users/NF/MobDev/Cocos/ProjectName/proj.android-studio/../cocos2d:/Users/NF/MobDev/Cocos/ProjectName/proj.android-studio/../cocos2d/cocos:/Users/NF/MobDev/Cocos/ProjectName/proj.android-studio/../cocos2d/external NDK_TOOLCHAIN_VERSION=4.9 NDK_DEBUG=1'

Android NDK: WARNING: Ignoring unknown import directory: /Users/NF/MobDev/Cocos/ProjectName/proj.android-studio/../cocos2d
Android NDK: WARNING: Ignoring unknown import directory: /Users/NF/MobDev/Cocos/ProjectName/proj.android-studio/../cocos2d/cocos
Android NDK: WARNING: Ignoring unknown import directory: /Users/NF/MobDev/Cocos/ProjectName/proj.android-studio/../cocos2d/external
Android NDK: jni/Android.mk: Cannot find module with tag './prebuilt-mk' in import path
Android NDK: Are you sure your NDK_MODULE_PATH variable is properly defined ?

My jni/Android.mk:

LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE := MyGame_shared
LOCAL_MODULE_FILENAME := libMyGame
LOCAL_SRC_FILES := hellocpp/main.cpp \
../../../Classes/AppDelegate.cpp \
../../../Classes/HelloWorldScene.cpp
LOCAL_C_INCLUDES := $(LOCAL_PATH)/../../../Classes
# COCOSHEADER_ANDROID_BEGIN
# COCOSHEADER_ANDROID_END
LOCAL_STATIC_LIBRARIES := cocos2dx_static
# COCOSLIB_ANDROID_BEGIN
# COCOSLIB_ANDROID_END
include $(BUILD_SHARED_LIBRARY)
#$(call import-module,.)
$(call import-module,./prebuilt-mk)
# COCOSLIB_IMPORT_ANDROID_BEGIN
# COCOSLIB_IMPORT_ANDROID_END

My build.gradle:

apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "23.0.3"
defaultConfig {
applicationId "org.cocos2dx.ProjectName"
minSdkVersion 10
targetSdkVersion 23
versionCode 1
versionName "1.0"
ext {
cocospath='/Users/NF/SDK/cocos2d-x-3.14.1'
}
externalNativeBuild {
ndkBuild {
targets "MyGame"
arguments "NDK_MODULE_PATH=$cocospath:$cocospath/cocos:$cocospath/external:$cocospath/cocos/prebuilt-mk:$cocospath/extensions"
arguments "-j" + Runtime.runtime.availableProcessors()
abiFilters "armeabi"
}
// available abiFilters (for debugging):
// abiFilters "x86", "armeabi", "armeabi-v7a", "arm64-v8a"
}
}
sourceSets.main {
java.srcDir "src"
res.srcDir "res"
jniLibs.srcDir "libs"
manifest.srcFile "AndroidManifest.xml"
assets.srcDir "assets"
}
externalNativeBuild {
ndkBuild {
path "jni/Android.mk"
}
}
signingConfigs {
release {
if (project.hasProperty("RELEASE_STORE_FILE")) {
storeFile file(RELEASE_STORE_FILE)
storePassword RELEASE_STORE_PASSWORD
keyAlias RELEASE_KEY_ALIAS
keyPassword RELEASE_KEY_PASSWORD
}
}
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
if (project.hasProperty("RELEASE_STORE_FILE")) {
signingConfig signingConfigs.release
}
}
}
}

dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile project(':libcocos2dx')
}

task cleanAssets(type: Delete) {
delete 'assets'
}
task copyAssets(type: Copy) {
from '../../Resources'
into 'assets'
}

clean.dependsOn cleanAssets
preBuild.dependsOn copyAssets

Posts: 1

Participants: 1

Read full topic

Installing a game created by cocos in windows

$
0
0

@heretic133 wrote:

Hey everybody
I have created a simple game using cocos creator. When I compile my project for windows everything is fine and the folder that contains 'myGame'.exe looks like this

My problem is that when I give this game to my friends they cant run it. the error says that they are missing MSVCR110D.dll . I have installed Microsoft Visual C++ Redistributable package for them but it still shows this error. What should I do ?

Posts: 3

Participants: 3

Read full topic

Slow initialization in Cocos2d-x 3.14.1

$
0
0

@drakon99 wrote:

Hi guys, :slight_smile:

Today I installed Cocos2d-x 3.14.1 to check if it works properly with my projects.
I noticed a big delay in the application init.
Every time I launch the app the program spend 8-10 seconds before printing:

platform initialization successful

Cocos2d-x 3.13.1 seems to work much better.
Does anyone had this problem?

My configuration:
Xcode 8.3.1
iPad mini 2 (iOS 10.3.1)

Posts: 1

Participants: 1

Read full topic

Cocos2d-x 3.11 Android Error help needed

$
0
0

@energyy wrote:

Hi,

we using cocos2d-x 3.11 and NDK 10, compiling against SDK 22 min SDK version 15 we getting following error for some users, can someone explain what wrong there.

java.lang.ExceptionInInitializerError
	at org.cocos2dx.lib.Cocos2dxActivity.onCreate(Cocos2dxActivity.java:267)
	at org.cocos2dx.cpp.AppActivity.onCreate(AppActivity.java:82)
	at android.app.Activity.performCreate(Activity.java:5015)
	at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1079)
	at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2057)
	at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2118)
	at android.app.ActivityThread.access$700(ActivityThread.java:136)
	at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1223)
	at android.os.Handler.dispatchMessage(Handler.java:99)
	at android.os.Looper.loop(Looper.java:137)
	at android.app.ActivityThread.main(ActivityThread.java:4903)
	at java.lang.reflect.Method.invokeNative(Native Method)
	at java.lang.reflect.Method.invoke(Method.java:511)
	at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:795)
	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:562)
	at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.NoClassDefFoundError: org.cocos2dx.lib.Cocos2dxHelper$1
	at org.cocos2dx.lib.Cocos2dxHelper.<clinit>(Cocos2dxHelper.java:121)
	... 16 more


java.lang.NoClassDefFoundError: org.cocos2dx.lib.Cocos2dxHelper$1
	at org.cocos2dx.lib.Cocos2dxHelper.<clinit>(Cocos2dxHelper.java:121)
	at org.cocos2dx.lib.Cocos2dxActivity.onCreate(Cocos2dxActivity.java:267)
	at org.cocos2dx.cpp.AppActivity.onCreate(AppActivity.java:82)
	at android.app.Activity.performCreate(Activity.java:5451)
	at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1093)
	at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2292)
	at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2386)
	at android.app.ActivityThread.access$900(ActivityThread.java:169)
	at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1277)
	at android.os.Handler.dispatchMessage(Handler.java:102)
	at android.os.Looper.loop(Looper.java:136)
	at android.app.ActivityThread.main(ActivityThread.java:5476)
	at java.lang.reflect.Method.invokeNative(Native Method)
	at java.lang.reflect.Method.invoke(Method.java:515)
	at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1283)
	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1099)
	at dalvik.system.NativeStart.main(Native Method)

Posts: 3

Participants: 2

Read full topic

C++ and Lua support for creator alpha0 released

$
0
0

@zhangxm wrote:

What's C++ and lua support for creator

It includes two parts:

  • First, it is a Cocos Creator plugin that can export scenes generated by Cocos Creator into .ccreator files.
  • Second, it has a reader that can parse .ccreator files. The reader can be used in cocos2d-x c++/lua project.

Download

There are two ways to get the plugin

How to use it

Requirements:

  • cocos2d-x: v3.14+
  • Cocos Creator: 1.4+

Steps to use:

  • download Cocos Creator
  • try the existing project in repo or copy plugin into your Cocos Creator project
  • use the plugin to generate needed files
  • use output of plugin and reader in your cocos2d-x projects

More detail information please refer to ReadMe.

You are appreciated to test it and report any bugs met. Any pull request is appreciated too.

Edit: the repo address changed from https://github.com/cocos2d/creator_to_cocos2dx_cpp to https://github.com/cocos2d/creator_to_cocos2dx to make it clear, because the plugin also supports Lua.

Posts: 7

Participants: 3

Read full topic


How to use mipmap in etc1?

$
0
0

@dlquh wrote:

can someone know why loaded ECT1 texture is - BLACK - on Android , when i try use mipmap?

	static cocos2d::Texture2D::TexParams tp = {
		GL_LINEAR_MIPMAP_LINEAR,
		GL_LINEAR,
		GL_REPEAT,
		GL_REPEAT
	};
	u_texture0->generateMipmap();
	u_texture0->setTexParameters(&tp);
	u_texture0->setAntiAliasTexParameters();

Posts: 1

Participants: 1

Read full topic

We should unify all cocos2d-x products in one product/app

$
0
0

@unrealsense wrote:

Hello guys,

First of all I am not 100% sure this is the best category for this post but because I think it can be seen as a feature request I decided to add it here.

I am new to cocos2d-x altough I have experience with other game engines/frameworks. I consider myself an enthusiast of game engines and software that happens to also be a game developer. So in my free time I like to tinker arround with the options out there.

I've been using unity since 3.5 , I have made a PC game on UDK with a team of 5 and played around with UE4. I have also played arround with lua frameworks like Corona and Gideros.

As a new commer to cocos2d-x I like what I see , I like the open source idea behind it , but the first time starting with cocos2d-x can be very, very confusing.

Let me explain. As you go to the products page of cocos2d-x there are 4 different products to download. There is cocos2d-x the framework , then there is the Cocos Creator with Cocos2d-Javascript (I think will support c++ in future), then Cocos and finally SDK Box for 3rd party software and plugins.

So while with others like Unity or UE4 there is only one download option here we have 4 which can confuse new users.

I started trying Cocos. So far it looked promissing , it downloads cocos2d-x for you and it even helps you download other stuff like the Android SDK or plugins from SDKBOX.
As a GUI to create projects seemed super decent as well giving me different options on how I want my project and even integrating plugins for me. Kudos on that. But then it also includes Coco Studio which is deprecated and the version of cocos2d-x is 3.10 instead of the latest 3.14. So I would be working on an outdated cocos2d-x.

Then we have the editors, there is Coco Studio which was working more or less with cocos2d-x but has been discontinued. We have also Cocos Creator that it feels way more mature than Cocos Studio with better integration with coding or scripting in this case but only for javascript. Besides that there is no real editor option for cpp.

With all this what I want to say is that there are a lot of options so many that its very confusing.

What its my proposal?

Lets do a suite that allows us to download only one app and from there download whatever its necessary in a modular way.

Lets do a cocos2d-x that its modular.

I think something very close to what Cocos already is but we could improve some options.

What if we make installing cocos2d-x somewhat very similar as it is for Unity. With Unity you download only one app then there you select in a list things you want to install and add (which require extra downloads handled by the same app). Things like platforms (iOS, Android, Windows Phone , Linux, etc..) and then Example Projects , Standard Assets, etc.

So here are some ideas.

We can do a main app called CocosSuite or whatever. Once you download this app and you install it then you can manage what things you want to download.

  • It should allow you to download and update the latest version of cocos2d-x available.

  • Downloading Cocos Creator or the editor for the scenes and UI should be an option appart (some people might not want to use the editor and just need the base cocos2d-x).

  • When you create a project the way cocos works I think its pretty good where you can select language and plugins . The only thing I would maybe add here is if the project will be meant to be used with editor or raw. Because projects seem to be a bit different from cocos2d-x and cocos editor. Maybe there is another way to solve this but I think this for now would be a good workaround.

  • Would be cool to add in the list to download examples in case someone wants to check the already pretty extense example projects and having always ther the option to navigate through different examples.

  • We could even add some UI options to do what cocos command line tool does but from UI like the build , run and deploy but made from a Graphical User Interface. Something like select your project and then another pop up appears with different options like platfrom , debug/release and actions (build,rung,...)

  • SDKBOX download option in case someone wants to adapt some of the plugins they are using altough I think making it seamles with the creation of the project and have it just ready to go is the best option for beginners.

I think cocos2d-x its doing some things right but there seems to be also a tendency to stop development on certain tools and leaving them half-finished like with Cocos Studio or with Cocos having only v3.10. If we could focus having a one soluton that integrates with all the products I am sure more people would have an easier time adopting this great framework.

So to make it short , unify everything in only one app and make it modular so the user can choose what he wants to use and what not with the possibility of adding it later. Also this should help keeping always the latest update or version of Cocos Editor and cocos2d-x.

Sorry for the long post and please let me know what you guys think about what I posted maybe other more experiences user have another point of view or can add some stuff they wished was there for them when they started.

Cheers and happy coding!

Posts: 2

Participants: 2

Read full topic

Cocos2d-x v3.15rc0 is released

$
0
0

@zhangxm wrote:

Download

cocos2d-x-3.15rc0.zip

Features

  • full Android Studio supports: include editing, compiling and debugging c++ codes: doc
  • audio engine uses tremolo to decode audio files on Android: high performance and more adaptable to different Android devices
  • WebSockets and SocketIO supports SSL
  • AssetsManagerEx is more stable
  • update Spine runtime to v3.5.35
  • update flatbuffer to v1.5
  • update OpenSSL to v1.1.0

Full release note can refer to here.

You are appreciated if you can test it and give some feedback. We will release final version in a week if not serious issues are found.

Posts: 8

Participants: 4

Read full topic

Finalists of a game competition - The unique team using cocos2dx!

$
0
0

@morgado wrote:

Hi from Rio de Janeiro!

We’re one of the finalists of a Brazilian game competition, “Campus Mobile”, and the unique group using cocos2dx.

To win the final challenge, we need YOU to test our game!

We just released the test version of our game ‘League of Kites’, for Android and iOS.

The Game: In ‘League of Kites’ you can connect with your friends on Facebook to battle and become the champion of the league. You can also choose different models of kites/ lines and play in different cities.

To test: Just visit our site http://leagueofkites.com/english.html and subscribe to receive the link to play!

Thanks a million!! :wink:

Posts: 1

Participants: 1

Read full topic

Set Position of a sprite on touch (Not using Default Camera)

$
0
0

@itsabhiaryan wrote:

I create a new Camera and set mask to a Layer in this way

// code inside init() method of my Layer class

    auto s = Director::getInstance()->getWinSize();
    auto visibleSize = Director::getInstance()->getVisibleSize();
    auto origin = Director::getInstance()->getVisibleOrigin();
    auto spritePos = Vec3(visibleSize.width / 2 + origin.x, visibleSize.height / 2 + origin.y, 0);

    camera = Camera::createPerspective(60, (float)s.width / s.height, 1.0, 1000);
    camera->setCameraFlag(CameraFlag::USER2);
    camera->setPosition3D(spritePos + Vec3(0, 0, s.height*.8));
    setCameraMask((unsigned short)CameraFlag::USER2, true);
    camera->lookAt(spritePos, Vec3(0.0, 1.0, 0.0));

on touchDown I set position of my player Sprite in this way but when I touch in middle of screen then that set position exact where I touched but when I move from center to any of side (in width or in height way). position of sprite start deviation from some value . In leftmost/ rightmost point deviation is width of player sprite.

player->setPosition(c.x,c.y);

How I set position without any deviation ?

Posts: 1

Participants: 1

Read full topic

Is there any PhysicsJointPin alternative in Box2d physics?

$
0
0

@sunil9038 wrote:

This code only worked with inbuilt physics. But i want to use box2d physics separately .

bool GameScene::onTouchBegan(Touch* touch, Event* event)
{
log("Touch called");
auto location = touch->getLocation();
auto arr = sceneWorld->getShapes(location);

PhysicsBody* body = nullptr;
for (auto& obj : arr)
{
    log("Touch getting");
    
    // if ((obj->getBody()->getTag() & DRAG_BODYS_TAG) != 0)
    {
        body = obj->getBody();
        break;
    }
}

if (body != nullptr)
{
    log("Touch got");
    
    Node* mouse = Node::create();
    auto physicsBody = PhysicsBody::create(PHYSICS_INFINITY, PHYSICS_INFINITY);
    physicsBody->setDynamic(false);
    mouse->addComponent(physicsBody);
    mouse->setPosition(location);
    this->addChild(mouse);
    PhysicsJointPin* joint = PhysicsJointPin::construct(physicsBody, body, location);
    joint->setMaxForce(3000.0f * body->getMass());
    sceneWorld->addJoint(joint);
    _mouses.insert(std::make_pair(touch->getID(), mouse));
    
    return true;
}

return false;
}

void GameScene::onTouchMoved(Touch* touch, Event* event)
{
auto it = _mouses.find(touch->getID());

if (it != _mouses.end())
{
    it->second->setPosition(touch->getLocation());
 }
 }

void GameScene::onTouchEnded(Touch* touch, Event* event)
{

auto it = _mouses.find(touch->getID());

if (it != _mouses.end())
{
    this->removeChild(it->second);
    _mouses.erase(it);
    
    //scheduleOnce(schedule_selector(GameContrler::checkTagetComplete),1);
  }
}

Posts: 1

Participants: 1

Read full topic

Android Studio and cocos2d-x v2.2.6

$
0
0

@nerbrothers wrote:

Hi All,

because of some performance critical reasons I have to use v2.2.6 for my game. Tried some v3 versions like 3.7, 3.11, 3.13.

And the performance is very low. But anyway with v2.2.6 and cricket audio engine everything works great at 60 fps with no lags.

Currently I use Eclipse with ADT and it works great. The only thing I cannot do is remote debugging on device.

In near future it gets more important to use Multi Dexing, so I'm wondering when there will be a proj.android-studio version for cocos2d-x? Or can I use the v3.14.1 proj.android-studio project and replace the cocos classes?

Is someone working with Android Studio and cocos2dx v2.2.6 or other v2?

Posts: 1

Participants: 1

Read full topic


[Solved] Prebuilt Libraries - gen-libs & NDK versions

$
0
0

@zx12a1 wrote:

Hi

I am following the link below to try and upgrade my build so I can debug in Android Studio.

I can build my cocos libraries using the following command:

cocos gen-libs -p android --ap android-25 --app-abi armeabi:x86:armeabi-v7a

Builds Ok using android-ndk-r10c. Any newer version r11c, 13b, 14b and I get a link error

./base/CCConsole.cpp:423: error: undefined reference to 'bzero'

cocos2d-x 3.14.1
Build tools 25.0.2
minSdk 9 target/compile Sdk 25

Help please?

(http://discuss.cocos2d-x.org/t/android-studio-support/35364/19)

Posts: 4

Participants: 2

Read full topic

[ERROR] using ndk 14 and build android

$
0
0

@adesuluh wrote:

when i change from ndk r10 to newest r14 i got this error when build with

cocos compile -p android --app-abi x86

after i set APP_ALLOW_MISSING_DEPS=true in application.mk, still
it got me error :

Android NDK: Module cocos2dcpp_shared depends on undefined modules: cocos_curl_static

my cocos version v3.10, I look at issue in github but don't know how to fix it :frowning: anyone can help?

Posts: 3

Participants: 2

Read full topic

Build for windows on linux using MigWin64

$
0
0

@v2003 wrote:

I develop and build cocos2d-x game (using lua) on linux and want to build windows version in place, but when I set -p win32 it says, that only linux, android and tizen build are aviable. I have installed all required packages for cross compiling (migwin64). Is cross building in cocos2d-x aviable for now, if not, is it planned in future?

Posts: 1

Participants: 1

Read full topic

Draw Node shape Confusion

$
0
0

@crazy_learner wrote:

if i want to create 2 shapes without using any sprite.Does i need two draw node object?

DrawNode * dn=DrawNode::create();
dn->drawSolidRect(cocos2d::Vec2::ZERO, Vec2(_visibleSize.width/4,_visibleSize.height/4),    Color4F::BLUE);
dn->drawSolidRect(cocos2d::Vec2::ZERO, Vec2(_visibleSize.width/2,_visibleSize.height/8), Color4F::RED);
this->addChild(dn);

Here, i have created two shapes with one object how can set diff. pos for both.

Posts: 1

Participants: 1

Read full topic

Windows 10 universal build failed

Viewing all 2748 articles
Browse latest View live