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

Anyone knows how to put banner ads at bottom of game?

$
0
0

@ousaf wrote:

I have iOS exported game project from cocos creator as the game opens in full screen so placing banner ad view as subview of game view makes banner ad overlay on the game canvas.

I want that banner ad appears separately below the game canvas like shown in following game.

Posts: 1

Participants: 1

Read full topic


APK size too big after build. Lib folder after unzip is over 1.3GB

$
0
0

@john_daniel wrote:

Hi everyone, I am using Android Studio to build android game, the apk file after build is too big. My resource just 180MB but final apk size is over 440MB. I try extract the apk file, and the lib folder is 1.3GB. I don’t know what is wrong. What am I missing here?
Cocos2d-JS v3.17
Android Studio 3.1
android-ndk-r16b

Posts: 1

Participants: 1

Read full topic

Cocos2d-x v4 adding new file after installing

$
0
0

@kemalb wrote:

Hi,

I was using v3.17 but Apple will not allow contains UIWebKit from April, 2020 for new app. So, I want to start new project with new version. I downloaded v4 from website. I created new project.

cocos new Test -l cpp -p com.Kemal.Test

After, I run cmake command according to docs (https://github.com/cocos2d/cocos2d-x/blob/v4/cmake/README.md#generate-macos-project).
I opened xcodeproj in ios-build folder. I fix bundle identifier and certificate for device running. It built. Here, I don’t have any problem.

Later, I created new header file and called “Definitions.h”. I include this file to HelloWorldScene.cpp (#include “Definitions.h”). And, ‘Definitions.h’ file not found. I don’t know that how to work cmake system but I added to list for cross-platforms.

list(APPEND GAME_HEADER
Classes/AppDelegate.h
Classes/HelloWorldScene.h
Definitions.h
)

In this time, Xcode build always cancelled. Also, I removed “Definitions.h” from list, but I can’t build. I checked signing and this values is removed. I fixed this values but this values is removed when I rebuild project. On the other hand, I’m trying to build for simulator and still cancelled.

How can I add new file to project?

Thanks.

Posts: 3

Participants: 2

Read full topic

Cocos2dx v4 run by xcode simulator

$
0
0

@imo0101 wrote:

I built with cocos2dx v4. I was able to build on the iPhone8(ios12.4).
But the simulator crashes.

simulator setting
Target ios 12.4 or 13.2
Simulator iPhone8 or 11

log
Metal API Validation Enabled**
Doesn’t support metal.
Doesn’t support metal.
Doesn’t support metal.
Doesn’t support metal.
Doesn’t support metal.

How can I solve it?
thank you.

Posts: 3

Participants: 2

Read full topic

Building a Facebook Instant Game?

$
0
0

@FILMon wrote:

Hi :slight_smile: first time Coco Citizen :slight_smile:

I want to build a really simple game but am having a lot of trouble doing the simplest stuff like a mouse button. Is there anyone who can help me get started. This is the simple game I want to build for Facebook Instant Games :slight_smile:

Posts: 3

Participants: 2

Read full topic

Run game on iPhone real device

$
0
0

@jonseg wrote:

Hi,

How can I run the game on an attached iPhone?
I execute:
cocos run -p ios

But It opens the simulator (that not support metal), so I want specify the iOS real device.

Thank you.

Posts: 2

Participants: 2

Read full topic

cocos js Particle effect does not work any more

$
0
0

@brighthead1995 wrote:

Hi, there, Happy new year

I’m using cocos js for some time, now i got a problem is that if i create a new gamemodel included a particle effect from a json file, the particle works very well, but if i reuse that object. the particle effect does not work any more, so how do I do to reuse a game model with particle effect? I’m using cocos 3.10 right now, cocos js version I believe is es5

Posts: 1

Participants: 1

Read full topic

Cocos2d-x v4 cocoapod not working


My code not error, but my game force stop

$
0
0

@ataf wrote:

hello everyone!

im new to all this cocos2d-x world, when i open level 1 my game force close,
this is my code “.h” and “.cpp”

level1.cpp (29.2 KB) level1.h (2.7 KB)

thanks

Posts: 2

Participants: 2

Read full topic

Physics collision cause program to abort

$
0
0

@OrionSteel wrote:

Hi. I am working on learning Cocos2d-x (v3.17.2) by programming the classic artillery game (2 cannons fire shells in hyperbolic arc at given angle and force - simple but covers basics of IO, sprites, etc.).

When my falling sprite’s edge (gravity physics) hits edge I placed on view, program aborts in source ccPhysicsBody.cpp L376:

void PhysicsBody::setPosition(float positionX, float positionY)
{
cpVect tt;

tt.x = positionX + _positionOffset.x;
tt.y = positionY + _positionOffset.y;

cpBodySetPosition(_cpBody, tt); // <--ABORT HERE

}

Based on test cpp and internet I have:

  1. Created scene and a sprite
  2. Added physic and gravity to scene and sprite - which now convincingly start falling and accelerating.
  3. Added an edge box to view like test cpp, and edge box to sprite
  4. Enabled debugging for physics and edges - I see box around sprite and view as expected.
  5. When sprite hits view edge, the sprite edge box goes a few pixels across view edge, and I get a program abort in void PhysicsBody::setPosition(float positionX, float positionY)

Can anyone offer suggestions to why collision leads to abort in physics code? What I missed / should change?
Note, if I remove the edge from sprite physics body it falls off screen as expected without crash, so I think problem is about physics and edges, not going off-screen.

My Code in scene init (some removed for clarity):

initWithPhysics();
getPhysicsWorld()->setGravity(Vec2(0, -980));

//Create edge around view
auto node = Node::create();
node->addComponent(PhysicsBody::createEdgeBox(VisibleRect::getVisibleRect().size));
node->setPosition(VisibleRect::center());
this->addChild(node);

getPhysicsWorld()->setDebugDrawMask(PhysicsWorld::DEBUGDRAW_ALL); //show collision boxes

//add cannon class’ sprite to scene
this->addChild(_cannon1.Sprite(), 2);

//add physics to sprite
auto pb = PhysicsBody::create();
pb->addShape(PhysicsShapeEdgeBox::create(_cannon1.Sprite()->getContentSize()));
_cannon1.Sprite()->setPhysicsBody(pb); //need edge or cannon falls through ground - if not here no crash

//place in center to fall
_cannon1.Sprite()->setPosition(Vec2(visibleSize.width / 2 + origin.x, visibleSize.height / 2 + origin.y));

this->scheduleUpdate();

return true;

Posts: 4

Participants: 3

Read full topic

Is it possible to get events (subscribe) from certain sprite?

$
0
0

@doxes wrote:

I want to check my physicsbody sprite is resting or not but I want it with best approach to performance reason.

Instead manually checking sprite isResting, sprite should emit resting event.
Does sprites can emit events?

Posts: 1

Participants: 1

Read full topic

_listView->removeAllItems() MEMORY LEAK

$
0
0

@dragon0962 wrote:

Hi all,

When I call (cocos2d::ui::Listview) _listView->removeAllItems() method , why all items of listview not released ? As you can see the output below, the ReferenceCount of all items is not decreased and the items is not released ! Is this a bug ?

Here is my code :

	std::vector<Widget*> stdList;

    for (int i = 0; i < _totalCount; ++i) {
        if (i < _spawnCount) {
            Widget* item = default_item->clone();
            item->setTag(i);
            Button* btn = (Button*)item->getChildByName("Title Button");
            btn->setTitleText(_array.at(i));
			stdList.push_back(btn);
			CCLOG("XXX BeFore btnRefC:%d ", btn->getReferenceCount());

            _listView->pushBackCustomItem(item);

			CCLOG("XXX After btnRefC:%d ", btn->getReferenceCount());
        }
    }

	_listView->removeAllItems();

	for (size_t i = 0; i < stdList.size(); i++)
	{
		if (auto object = stdList.at(i))
		{
			CCLOG("object RefC:%d ", object->getReferenceCount());
		}
	}

And here is the output

XXX BeFore btnRefC:2 
XXX After btnRefC:2 
XXX BeFore btnRefC:2 
XXX After btnRefC:2 
XXX BeFore btnRefC:2 
XXX After btnRefC:2 
XXX BeFore btnRefC:2 
XXX After btnRefC:2 
XXX BeFore btnRefC:2 
XXX After btnRefC:2 
object RefC:2 
object RefC:2 
object RefC:2 
object RefC:2 
object RefC:2

Could someone help me explain about this issue ? Thanks !

Posts: 2

Participants: 2

Read full topic

Crash with new AudioEngine code in v4.0

$
0
0

@BonBonSlick wrote:

This error exists in cocos2d v4.0
bool PlayScene::init()
{
if (!Scene::init())
{
return false;
}
AudioEngine::preload(“sounds/hit.mp3”);

....
	AudioEngine::play2d("sounds/hit.mp3");

Then when game closed, exception thrown.

Posts: 2

Participants: 2

Read full topic

Follow and unfollow sprite

$
0
0

@doxes wrote:

I am trying to follow and unfollow sprite by using this->runAction(action) and this->stopAction(action)

this error thrown (but If i use run-stop actions out of schedule scope it works):

Exception thrown: read access violation.
action->**** was 0xDDDDDDDD.

virtual studio focused this file CCActionManager.cpp line 193 :
action->startWithTarget(target);

function is
void ActionManager::addAction(...)

my code:
in header:

cocos2d::Action * followTheSprite;

HelloWorld::init :

    followTheSprite = Follow::create(sprite3, Rect(0, 0, 0, 0));
    Director::getInstance()->getScheduler()->schedule([&](float dt){

        // doesnt work here, but this line works out of schedule scope,
    	this->runAction(followTheSprite);

    	}, this, 1.5f, false, "schedulerKey");
  • I use schedule because I need to check sprite whether is stopped or not

Posts: 8

Participants: 3

Read full topic

TableView's inconsistent behaviour

$
0
0

@nedumaran wrote:

I am using TableView in two different areas in my app. The behaviour is strangely different while I think the code is similar. The desired behaviour is as in the video below. When I pull down it snaps back to the top. When I pull up, the cells are truncated at the top and it snaps back. The cells do not go pass the top. The code for this follows:

pagesTableView = TableView::create(this, Size(panelWidth, contentHeight));
pagesTableView->setAnchorPoint(Vec2::ANCHOR_BOTTOM_LEFT);
pagesTableView->setPosition(Vec2(xp,yp));
pagesTableView->setVerticalFillOrder(TableView::VerticalFillOrder::TOP_DOWN);
pagesTableView->setDelegate(this);

The next table view does not clip off the top. The cells go pass the top position, and do not snap back.

itemsTableView = TableView::create(this, Size(contentWidth, contentHeight));
itemsTableView->setAnchorPoint(Vec2::ANCHOR_BOTTOM_LEFT);
itemsTableView->setPosition(Vec2(xLeft, yBottom));
itemsTableView->setVerticalFillOrder(TableView::VerticalFillOrder::TOP_DOWN);
itemsTableView->setDelegate(this);

I am not sure what I’m missing. Perhaps there is some undetermined default that I am not setting.

Any help appreciated. Thank you.

Posts: 2

Participants: 1

Read full topic


How to get position of sprite on visible rect

$
0
0

@doxes wrote:

Suppose I have sprite and i set its position randomly, how can determine sprite is visible on screen or not and if visible get relative location on screen.

I am asking this to make mario style follow.
Follower shouldn’t follow sprite when its on screen center-200 between screen center+200

I tried Follow::createWithOffset looks like doesnt work intended or I missing something.

for example
Follow::createWithOffset(sprite3, 200, 0, Rect(0,-3200, 4000, 800));

this works intended follows sprite at xOffset 200, if I only move player right to left its still follow player at same xOffset 200 point.

any suggestion about usage of createWithOffset?
thank you

Posts: 11

Participants: 2

Read full topic

Is SimpleAudioEngine being maintained in the future?

$
0
0

@digimikeh wrote:

Hello!

I’m still a bit confused on how to reuse a clip on AudioEngine library, but it is not necessary for my game to use it, so i can switch back to SimpleAudioEngine…

I have downloaded v4.0 since i will work for iOS too…
Will you deprecate the SimpleAudioEngine library in the future?.. can i use it securely?.

Thanks!

Posts: 2

Participants: 2

Read full topic

How to take iOS build in CMake(3.16.2) of Cocos2d-x-4.0

$
0
0

@Sumanth_kumar wrote:

Hi,

I’am facing a issue in taking new iOS build in Cocos2d-x-4.0, where i’am using CMake(3.16.2) also.
Xcode(10.1) is the code editor.

Usually we used to take debug build in the Xcode interface itself, now am not even getting list of simulators when I started to use Cocos2d-x-4.0

Please do come up solutions, So thanks in ADVANCE.

Thank You.

Posts: 1

Participants: 1

Read full topic

Cocos2dx 3.17 Android Studio curl linker error

$
0
0

@NairodSuraidal wrote:

Environment:
Windows 10
Cocos2dx 3.17.2
Android Studio 3.5.3

Hello I am using a roughly new cocos2dx project android studio project and everything works fine until i add in #include <curl/curl.h> and then i get the following error.

FAILED: …/…/…/…/build/intermediates/cmake/debug/obj/arm64-v8a/libMyGame.so
cmd.exe /C “cd . && C:\android-ndk-r20b\toolchains\llvm\prebuilt\windows-x86_64\bin\clang++.exe --target=aarch64-none-linux-android21 --gcc-toolchain=C:/android-ndk-r20b/toolchains/llvm/prebuilt/windows-x86_64 --sysroot=C:/android-ndk-r20b/toolchains/llvm/prebuilt/windows-x86_64/sysroot -fPIC -g -DANDROID -fdata-sections -ffunction-sections -funwind-tables -fstack-protector-strong -no-canonical-prefixes -fno-addrsig -Wa,–noexecstack -Wformat -Werror=format-security -frtti -fexceptions -fsigned-char -O0 -fno-limit-debug-info -fno-experimental-isel -Wl,–exclude-libs,libgcc.a -Wl,–exclude-libs,libatomic.a -static-libstdc++ -Wl,–build-id -Wl,–warn-shared-textrel -Wl,–fatal-warnings -Wl,–no-undefined -Qunused-arguments -Wl,-z,noexecstack -shared -Wl,-soname,libMyGame.so -o …\build\intermediates\cmake\debug\obj\arm64-v8a\libMyGame.so CMakeFiles/MyGame.dir/Classes/AppDelegate.cpp.o CMakeFiles/MyGame.dir/Classes/helper/cocos2dxSpriteSheetHelper/SpriteSheetHelper.cpp.o CMakeFiles/MyGame.dir/Classes/helper/cocos2dxMusicPlayerHelper/MusicPlayerHelper.cpp.o CMakeFiles/MyGame.dir/Classes/helper/cocos2dxRapidJsonHelper/RapidJsonHeader.cpp.o CMakeFiles/MyGame.dir/Classes/helper/cocos2dxLanguageManagerHelper/LanguageManagerHelper.cpp.o CMakeFiles/MyGame.dir/Classes/helper/cocos2dxWebSocketsHelper/WebSocketClientHelper.cpp.o CMakeFiles/MyGame.dir/Classes/helper/cocos2dxWebSocketsHelper/WebSocketClientHelper.c.o CMakeFiles/MyGame.dir/Classes/helper/cocos2dxWebSocketsHelper/WebSocketClientProtocolsHelper.c.o CMakeFiles/MyGame.dir/Classes/helper/cocos2dxCurlHelper/CurlHttpHelper.c.o CMakeFiles/MyGame.dir/Classes/helper/cocos2dxGenFunctionsHelper/GenFunctionsHelper.cpp.o CMakeFiles/MyGame.dir/Classes/FirstBootScene.cpp.o CMakeFiles/MyGame.dir/Classes/MainScene.cpp.o CMakeFiles/MyGame.dir/proj.android/app/jni/hellocpp/main.cpp.o CMakeFiles/MyGame.dir/Classes/pp_helper_class.cpp.o -Wl,–whole-archive engine/cocos/platform/libcpp_android_spec.a -Wl,–no-whole-archive lib/libcocos2d.a lib/libexternal.a …/…/…/…/…/…/cocos2d/external/Box2D/prebuilt/android/arm64-v8a/libbox2d.a …/…/…/…/…/…/cocos2d/external/chipmunk/prebuilt/android/arm64-v8a/libchipmunk.a …/…/…/…/…/…/cocos2d/external/freetype2/prebuilt/android/arm64-v8a/libfreetype.a lib/libext_recast.a …/…/…/…/…/…/cocos2d/external/jpeg/prebuilt/android/arm64-v8a/libjpeg.a …/…/…/…/…/…/cocos2d/external/webp/prebuilt/android/arm64-v8a/libwebp.a …/…/…/…/…/…/cocos2d/external/bullet/prebuilt/android/arm64-v8a/libLinearMath.a …/…/…/…/…/…/cocos2d/external/bullet/prebuilt/android/arm64-v8a/libBulletDynamics.a …/…/…/…/…/…/cocos2d/external/bullet/prebuilt/android/arm64-v8a/libBulletCollision.a …/…/…/…/…/…/cocos2d/external/bullet/prebuilt/android/arm64-v8a/libLinearMath.a …/…/…/…/…/…/cocos2d/external/bullet/prebuilt/android/arm64-v8a/libBulletMultiThreaded.a …/…/…/…/…/…/cocos2d/external/bullet/prebuilt/android/arm64-v8a/libMiniCL.a …/…/…/…/…/…/cocos2d/external/tiff/prebuilt/android/arm64-v8a/libtiff.a …/…/…/…/…/…/cocos2d/external/websockets/prebuilt/android/arm64-v8a/libwebsockets.a …/…/…/…/…/…/cocos2d/external/uv/prebuilt/android/arm64-v8a/libuv_a.a …/…/…/…/…/…/cocos2d/external/openssl/prebuilt/android/arm64-v8a/libssl.a …/…/…/…/…/…/cocos2d/external/openssl/prebuilt/android/arm64-v8a/libcrypto.a lib/libext_tinyxml2.a lib/libext_xxhash.a lib/libext_xxtea.a lib/libext_clipper.a lib/libext_edtaa3func.a lib/libext_convertUTF.a lib/libext_poly2tri.a lib/libext_md5.a …/…/…/…/…/…/cocos2d/external/curl/prebuilt/android/arm64-v8a/libcurl.a …/…/…/…/…/…/cocos2d/external/png/prebuilt/android/arm64-v8a/libpng.a engine/external/android-specific/cpufeatures/libext_cpufeatures.a -ldl lib/libext_pvmp3dec.a lib/libext_tremolo.a …/…/…/…/…/…/cocos2d/external/zlib/prebuilt/android/arm64-v8a/libz.a lib/libext_unzip.a -lGLESv2 -lEGL -llog -landroid -lOpenSLES -latomic -lm && cd .”
…/…/…/…/…/…/cocos2d/external/curl/prebuilt/android/arm64-v8a/libcurl.a(libcurl_la-openssl.o): In function ossl_connect_common': vtls/openssl.c:(.text.ossl_connect_common+0xbac): undefined reference to PKCS12_parse’
vtls/openssl.c:(.text.ossl_connect_common+0x15a8): undefined reference to BIO_f_ssl' ../../../../../../cocos2d/external/curl/prebuilt/android/arm64-v8a/libcurl.a(libcurl_la-openssl.o): In function Curl_ossl_version’:
vtls/openssl.c:(.text.Curl_ossl_version+0x1c): undefined reference to OpenSSL_version_num' ../../../../../../cocos2d/external/curl/prebuilt/android/arm64-v8a/libcurl.a(libcurl_la-openssl.o): In function Curl_ossl_seed’:
vtls/openssl.c:(.text.Curl_ossl_seed+0x88): undefined reference to RAND_load_file' vtls/openssl.c:(.text.Curl_ossl_seed+0xe0): undefined reference to RAND_file_name’
vtls/openssl.c:(.text.Curl_ossl_seed+0xf4): undefined reference to RAND_load_file' ../../../../../../cocos2d/external/curl/prebuilt/android/arm64-v8a/libcurl.a(libcurl_la-openssl.o): In function ossl_send’:
vtls/openssl.c:(.text.ossl_send+0x120): undefined reference to OpenSSL_version_num' ../../../../../../cocos2d/external/curl/prebuilt/android/arm64-v8a/libcurl.a(libcurl_la-openssl.o): In function servercert’:
vtls/openssl.c:(.text.servercert+0x1b5c): undefined reference to OCSP_response_status_str' vtls/openssl.c:(.text.servercert+0x1bf8): undefined reference to OCSP_basic_verify’
vtls/openssl.c:(.text.servercert+0x1c64): undefined reference to OCSP_cert_status_str' vtls/openssl.c:(.text.servercert+0x1ec0): undefined reference to OCSP_crl_reason_str’

it seems like a linker error but i am confused because doesn’t the android.mk in the external/curl/android folder already link curl and the respective openssl?

Posts: 1

Participants: 1

Read full topic

Compiling cocos2d-x sample LiquidFun-Testbed Xcode 10.2 - Missing files on compile-time

$
0
0

@hansah wrote:

I’ve been trying to build the cocos2d-x samples by following the steps from https://github.com/cocos2d/cocos2d-x-samples exactly, namely

Download

$ git clone https://github.com/cocos2d/cocos2d-x-samples.git

$ cd cocos2d-x-samples $ python download-engine.py

Running

Once the samples were downloaded just go any sample, and open the project. eg:

$ cd cocos2d-x-samples/samples/LiquidFun-Testbed/proj.ios_mac

$ open LiquidFun-Testbed.xcodeproj/

However, when I build the LiquidFun-Testbed.xcodeproj, while targeting iOS, I get

Showing All Errors Only

Prepare build
note: Using legacy build system


Build target libcocos2d iOS of project cocos2d_libs with configuration Debug


Build target LiquidFun-Testbed iOS of project LiquidFun-Testbed with configuration Debug

clang: error: no such file or directory: '/Users/Chris/Desktop/source/repos/3rd party libraries/cocos2d-x-samples/libs/liquidfun/liquidfun/liquidfun/Box2D/Box2D/Dynamics/Contacts/b2EdgeAndPolygonContact.cpp'
clang: error: no input files

clang: error: no such file or directory: '/Users/Chris/Desktop/source/repos/3rd party libraries/cocos2d-x-samples/libs/liquidfun/liquidfun/liquidfun/Box2D/Box2D/Collision/b2Distance.cpp'
clang: error: no input files

clang: error: no such file or directory: '/Users/Chris/Desktop/source/repos/3rd party libraries/cocos2d-x-samples/libs/liquidfun/liquidfun/liquidfun/Box2D/Box2D/Common/b2StackAllocator.cpp'
clang: error: no input files



Build failed    06.01.20, 22:25    698.2 seconds

It looks like the compiler is looking for files in

/Users/Chris/Desktop/source/repos/3rd party libraries/cocos2d-x-samples/libs/liquidfun/liquidfun/liquidfun/Box2D/Box2D/

but this path was never created.

After following the mentioned steps above, Box2D and its code are instead placed in

/Users/Chris/Desktop/source/repos/3rd party libraries/cocos2d-x-samples/libs/cocos2d-x/external/Box2D

…So I am wondering

A) Why is it looking for these files in

/Users/Chris/Desktop/source/repos/3rd party libraries/cocos2d-x-samples/libs/liquidfun/liquidfun/liquidfun/Box2D/Box2D/ ?

B) What can I do to fix this and get these samples to build?

Posts: 1

Participants: 1

Read full topic

Viewing all 2747 articles
Browse latest View live