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

how to import third party modules like a folder in cocos2d js

$
0
0

@TheKeeper wrote:

I have written modules for Facebook, Ads , Onesignal and etc… which i was using for other projects with other engines and frameworks, I would like to use the same again in cocos2djs, Is there any easiest way possible for this? Just like (import facebook) and use this?

Posts: 1

Participants: 1

Read full topic


delaytime is not working in sequence

$
0
0

@Arun55 wrote:

var scale = new cc.scaleTo(0.3,0.0);
var delay = new cc.DelayTime(1.0);
var callFunc1 = new cc.CallFunc(ImageManagerObj.setEnableFrames(true), ImageManagerObj);
var seq = new cc.Sequence(scale,delay,callFunc1);
m_BgZoomSpr.runAction(seq);

delaytime is not working its calling instantly in cocos2d js
i have checked other topics related to this i didn’t found solution
can any one help me out this one

Posts: 1

Participants: 1

Read full topic

Help with appleTV target

$
0
0

@FelixFox wrote:

I’m not very experienced with cocos2dx, but I like it a lot.
Can someone let me know how can I create a target of my project to run on AppleTV?
When creating the target I can only choose between objective-C and Swift. Shouldn’t C++ be available?
Which cocos 2dx libraries should I include?
Where can I learn about this? I can’t seem to find relevant information anywhere.

Cheers,

Posts: 1

Participants: 1

Read full topic

Different problems with a cocos::Vector

$
0
0

@abrajam wrote:

Hello community, I always have had problems with this kind of object, the thing is that I am following a tutorial http://seryusjj.github.io and this guy manages vectors to pointers to subclassed Sprites as a cocos::Vector, the problem is that when you try to pass the Vector as a reference to a member function and try to copy elements from it gives a lot of kind of errors in compilation.

For example, this is the code of the function
void Player::setTargets(cocos2d::Vector<BasicEnemy *> &targets){

    for(int i; i < targets.size(); ++i)
        _targets.pushBack(targets.at(i));

    for (int i = 0; i < _numBullets; i++){
        _bulletPool.at(i)->setPlayerTargets(_targets);
        }
}

and this is the errors I get…

error: static_assert failed due to requirement 'std::is_convertible<BasicEnemy *, cocos2d::Ref *>::value' "Invalid Type for cocos2d::Vector<T>!"
        static_assert(std::is_convertible<T, Ref*>::value, "Invalid Type for cocos2d::Vector<T>!");

error: member access into incomplete type 'BasicEnemy'

Posts: 4

Participants: 2

Read full topic

Assertion failed: CCSpriteBatchNode only supports Sprites as children

$
0
0

@SimonArchNox wrote:

Hello fellow developers.
Working on a game that involves a timer. I did some research and was happy to find ProgressTimer.
Thing is my game crashes due to an assertion failure: CCSpriteBatchNode only supports Sprites as children.
I’m using version 3.16 and developing using cpp.

See code below and more details.
*.h
ProgressTimer* _cardTimer;

*.cpp
_cardTimer = ProgressTimer::create(Sprite::createWithSpriteFrameName("timerSprite.png"));
_cardTimer->setPosition(Vec2(_screenSize.width * 0.5f, _screenSize.height * 0.6879f));
_cardTimer->setType(ProgressTimer::Type::RADIAL);
_cardTimer->setPercentage(0.0f);
_spriteBatchNode->addChild(_cardTimer, kzForeground);

Assertion happens when program reaches the statement: _spriteBatchNode->addChild(_cardTimer, kzForeground);
Exact fail location is CCSpriteBatchNode.cpp:192

Am I missing something here or is it actually a bug??
Will pay with cat emojis for help :smiley_cat:

Posts: 7

Participants: 3

Read full topic

Problem about DelayTime

$
0
0

@Refetizm wrote:

Hi everyone,

I need to spawn sprites at different times. Therefore i used “DelayTime” and “Sequence”. First of all i build a class in different cpp file.

    TeamCut::TeamCut(cocos2d::Layer* layer)
{
	teamPipeSprite = Sprite::create("TeamPipe.png");
	teamPipeSprite->setAnchorPoint(Vec2(0.0, 0.0));
	teamPipeSprite->setPosition(Point(750, 750));
	layer->addChild(teamPipeSprite, 5);
}

and than i wrote that code for spawn my sprite:

auto noder = Node::create();
	
auto delayer = DelayTime::create(5.0);

auto seq = Sequence::create(delayer, TeamCut(this), nullptr);
	
noder->runAction(seq);

When i run the code my sprite spawned right now, not 5 seconds later. Where is the problem ?

Posts: 12

Participants: 5

Read full topic

MathUtil::lerp alpha parameter

$
0
0

@digimikeh wrote:

Hi there…

I suspect MathUtil::lerp() interpolates between a float to another, those are the first two parameters, so i guess it needs update in order to work isn"t?

I have used update correctly ( because i tested with CCLOG and works printing for ever) and put this:

void myScene::update(float dt){
    CCLOG("%f", MathUtils::lerp(0.0f, 1.0f, 1));
}

But console prints out :

1
1
1
... //for ever

If i change the third argument value to 0, then it prints 0 for ever in the log… So as you can see, no matter what range i put, it keeps printing the alpha value, is like args 0 and 1 are being skipped

What is alpha parameter for?
https://docs.cocos2d-x.org/api-ref/cplusplus/V3.6/de/dbd/classcocos2d_1_1_math_util.html#a684e6e4d2f7bd48dd4a8832bb2e40f0b

Posts: 5

Participants: 2

Read full topic

about Cocos2dx C++ physicsbody

$
0
0

@imo0101 wrote:

I’m in trouble. There is a problem when the flipper rebounds the ball. When the flipper is raised, the ball will sink into the flipper. Please tell me how to resolve.

// ball material setting
ballBody = MyBodyParser::getInstance()->bodyFormJson(ballSpr, “ball”, PhysicsMaterial(0.2f, 0.0f, 0.0f));

if (ballBody != nullptr)
{
    ballBody->setMass(10.0);
    ballBody->setMoment(100.0f);
    ballBody->setDynamic(true);
    ballBody->setRotationEnable(true);
    ballBody->setCategoryBitmask(ball_MASK);
    ballBody->setCollisionBitmask(flipper_MASK);
    ballBody->setContactTestBitmask(true); 
    ballSpr->setPhysicsBody(ballBody);
}

// flipper material setting
flipperBody = MyBodyParser::getInstance()->bodyFormJson(flipperSpr, “flipper”, PhysicsMaterial(1.0f, 0.0f, 0.0f));

if (flipperBody != nullptr)
{
    flipperBody->setMass(90.0);
    flipperBody->setMoment(10000000.0f);
    flipperBody->setDynamic(true);
    flipperBody->setRotationEnable(true);
    flipperBody->setCategoryBitmask(flipper_MASK);
    flipperBody->setCollisionBitmask(ball_MASK);
    flipperBody->setContactTestBitmask(true); 
    flipperSpr->setPhysicsBody(flipperBody);
}

Posts: 1

Participants: 1

Read full topic


crash in libwebviewchromium.so and admob interstitial

$
0
0

@ebouchard wrote:

I know there is another thread from back in 2018, but the solutions proposed in there did not work and I do have the same issue. It seems related to interstitial with admob on Android 4.4.x devices.

I tried removing hardware acceleration in the android manifest but crash is still present:

I am using the version com.google.android.gms:play-services-ads:15.0.1.

I tried the latest version but it crashes at application launch, so I did not continue on that path.

One of the person in that thread proposed to remove the advertisement all-together for the 4.4.x devices. This is a last resort, however, there are no Cocos2d command to retrieve the API level (from what I could find at least).

So I am kinda stuck with the app crashing quite a lot on the 4.4.x devices. Any suggestions?

Posts: 2

Participants: 2

Read full topic

cocos3dx v3.10 js require

$
0
0

@brighthead1995 wrote:

I’m using cocos2dx for some years, but i’m new in js, now I’ve face to a problem:

my cocos version is 3.10, which I can not change, so update engine is not an option
I need using the setence “require(‘xxxxx’)” in this js project when i intergrate a 3rd sdk, how do i achive that? because if i’m using the require sentence directly, the main.js does not work, could i get some advice or suggestion

Posts: 1

Participants: 1

Read full topic

SDKBox Initialize problem

$
0
0

@hjaison wrote:

Hi Everyone.
I wasted 2 days on this problem, but still not sure what I have to do.
I installed SDKBox into cocos2d-x-lua v3.17.2 with SDKBox_GUI(v1.1.7)

This cocos2d-x project is an empty project, and it shows helloworld well before I install SDKBox.
After I install that, it is compiled and could be run, but crashed at the beginning.

I digged into many articles, but still can’t find the issue and the solution.
Here is the screenshot of Android.mk, Application.mk

Android.mk

Application.mk

Here is the log I could get on logcat

10-21 16:25:45.358: W/dalvikvm(3395): No implementation found for native Lcom/sdkbox/plugin/SDKBox;.nativeInit:(Ljava/lang/Object;Ljava/lang/ClassLoader;)V
10-21 16:25:45.358: D/AndroidRuntime(3395): Shutting down VM
10-21 16:25:45.358: W/dalvikvm(3395): threadid=1: thread exiting with uncaught exception (group=0xa4ce6b20)
10-21 16:25:45.358: E/AndroidRuntime(3395): FATAL EXCEPTION: main
10-21 16:25:45.358: E/AndroidRuntime(3395): Process: com.jaison.glory, PID: 3395
10-21 16:25:45.358: E/AndroidRuntime(3395): java.lang.UnsatisfiedLinkError: Native method not found: com.sdkbox.plugin.SDKBox.nativeInit:(Ljava/lang/Object;Ljava/lang/ClassLoader;)V
10-21 16:25:45.358: E/AndroidRuntime(3395): at com.sdkbox.plugin.SDKBox.nativeInit(Native Method)
10-21 16:25:45.358: E/AndroidRuntime(3395): at com.sdkbox.plugin.SDKBox.init(SDKBox.java:71)
10-21 16:25:45.358: E/AndroidRuntime(3395): at com.sdkbox.plugin.SDKBoxActivity.onCreate(SDKBoxActivity.java:13)
10-21 16:25:45.358: E/AndroidRuntime(3395): at org.cocos2dx.lua.AppActivity.onCreate(AppActivity.java:36)
10-21 16:25:45.358: E/AndroidRuntime(3395): at android.app.Activity.performCreate(Activity.java:5231)
10-21 16:25:45.358: E/AndroidRuntime(3395): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087)
10-21 16:25:45.358: E/AndroidRuntime(3395): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2148)
10-21 16:25:45.358: E/AndroidRuntime(3395): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2233)
10-21 16:25:45.358: E/AndroidRuntime(3395): at android.app.ActivityThread.access$800(ActivityThread.java:135)
10-21 16:25:45.358: E/AndroidRuntime(3395): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1196)
10-21 16:25:45.358: E/AndroidRuntime(3395): at android.os.Handler.dispatchMessage(Handler.java:102)
10-21 16:25:45.358: E/AndroidRuntime(3395): at android.os.Looper.loop(Looper.java:136)
10-21 16:25:45.358: E/AndroidRuntime(3395): at android.app.ActivityThread.main(ActivityThread.java:5001)
10-21 16:25:45.358: E/AndroidRuntime(3395): at java.lang.reflect.Method.invokeNative(Native Method)
10-21 16:25:45.358: E/AndroidRuntime(3395): at java.lang.reflect.Method.invoke(Method.java:515)
10-21 16:25:45.358: E/AndroidRuntime(3395): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
10-21 16:25:45.358: E/AndroidRuntime(3395): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:609)
10-21 16:25:45.358: E/AndroidRuntime(3395): at dalvik.system.NativeStart.main(Native Method)
10-21 16:25:45.358: W/ActivityManager(454): Force finishing activity com.jaison.glory/org.cocos2dx.lua.AppActivity

This is my first time on SDKBox, and I will be very glad if I can use this instead of other packages for IAP, ADS and Rate & Share.
Thanks

Posts: 1

Participants: 1

Read full topic

AudioEngine how to use it?

$
0
0

@digimikeh wrote:

Hi…
What do audioID and AudioProfile parameters are for in cocos2d::experimental::AudioEngine and how to use them?

Thanks…

Posts: 4

Participants: 2

Read full topic

Change Font Colour In The Same Text

$
0
0

@Refetizm wrote:

Hi everyone,

I wrote a code for dialogues:

label = CCLabelBMFontAnimated::createWithTTF("", "fonts/PressStart2P.ttf", 20.0f,
	Size(visibleSize.width, 40),
	cocos2d::TextHAlignment::CENTER, cocos2d::TextVAlignment::CENTER);
label->setTextColor(Color4B::BLACK);

label->setString("WE_HAVE_DOZENS_OF_PAPERWORK!!!");

I need to change “_” character’s colour to white. Is it possible ?

Posts: 4

Participants: 3

Read full topic

Memory management in cocos2d-x c++

$
0
0

@nirobkuet wrote:

Hi
I am working on cocos2d-x c++(v3.16). I am facing a horrible problem related to memory management. Let’s describe the problem :-

I have a class like SkeletonAnimation of cocos2d-x library named ProductBody inherited from Node which is used to animate Products(Dragons, Dinos etc). I have another class named FighterAnimation inherited from ProductBody.

I have another class named FightDragon where the dragons do fight against opponent dragons.
In FightDragon class I create two objects of FighterAnimation are deathAnimation and powerAnimation. I have to remove deathAnimation and powerAnimation after the animation sequence done. After that deathAnimation and powerAnimation is created. In this loop I notice that deathAnimation and powerAnimation is altered. This is the problem. I don’t know why this is happening.
My classes are below :-

ProductBody.h

class ProductBody : public Node
{
public :
virtual ~ProductBody();
ProductBody();
static ProductBody* create();
// another several functions here
}

ProductBody.cpp

ProductBody::~ProductBody() {}
ProductBody::ProductBody() {}

ProductBody* ProductBody::create()
{
ProductBody* ret = new ProductBody();
if(ret && ret->init()) {
ret->autorelease();
return ret;
} else {
delete ret;
ret = nullptr;
return nullptr;
}
}

`

FighterAnimation.h

class FighterAnimation: public ProductBody
{
private :
virtual ~FighterAnimation();
FighterAnimation();
static FighterAnimation* create( int product, int mylevel, bool movement);
// another several functions here
}

FighterAnimation.cpp

FighterAnimation::~FighterAnimation() {}
FighterAnimation::FighterAnimation() {}

FighterAnimation* FighterAnimation::create( int product, int mylevel, bool movement)
{
FighterAnimation* ret = new FighterAnimation();
if (ret && ret->init(product, mylevel, movement)) {
ret->autorelease();
return ret;
} else {
delete ret;
ret = nullptr ;
return nullptr ;
}
}

FightDragon.h

class FightDragon : public Node
{
public :
~FightDragon();
FightDragon();
FighterAnimation *deathAnimation;
FighterAnimation *powerAnimation;
void loadAnimation();
}

FightDragon.cpp

FightDragon::~FightDragon() {}
FightDragon::FightDragon() {}

FightDragon* FightDragon::create()
{
FightDragon* ret = new FightDragon();
if(ret && ret->init()) {
ret->autorelease();
return ret;
} else {
delete ret;
ret = nullptr;
return nullptr;
}
}

void FightDragon::loadAnimation()
{
deathAnimation=FighterAnimation::create(8202, ageBaby, false , folderName);
powerAnimation=FighterAnimation::create(7326,ageAdult, false ,folderName);
}

When I check deathAnimation->productid it prints 7326 but should prints 8202 and powerAnimation->productid it prints 8202 but should prints 7326.
In short, these two objects are altered sometimes, I repeat altered sometimes. It means this is not happen all time.
Please help.
Thanks in advance

Posts: 4

Participants: 2

Read full topic

RenderTexture multiple draws

$
0
0

@Jack_Wiebe wrote:

Hi there!

I am using a RenderTexture to visit a bunch of sprite that are part of a animation node. The purpose of this is to apply a single shader to the render texture once it has visited each texture from the animation.

My problem is currently it is now drawing the animation twice, once for the actual animation node and agian for the render texture. If I try and remove the original animation from its parent or set its visibilty to false, the renderTexure doesn’t capture the new animation frames.

Is there a good way to keep my animation playing while but not increase my draw calls?

Posts: 6

Participants: 4

Read full topic


RenderTexture and setVirtualViewport

$
0
0

@Jack_Wiebe wrote:

I have a question regarding RenderTexture and the method setVirtualViewport
I am try to draw to a small rectangle from a bunch of nodes.

What I am trying to achieve is setting the viewPort of my renderTexture to be a small rectangle and whenever a node passes through the area of the renderTexture viewport I want it to draw to the texture, while keeping its original scale

Posts: 1

Participants: 1

Read full topic

Load SVG file format

ScrollView: scroll outside contentsize problem

$
0
0

@ComputerDev wrote:

Hello,
My scroll is working but when I exit the ContentSize() by keeping my finger on the screen, the scroll is stopped. It’s binding if your scroll does not make the screensize.

Thanks

Posts: 1

Participants: 1

Read full topic

How to hide status bar in ios13 in cocos-2dx

$
0
0

@VBilokin wrote:

Hi everyone,

I was using:
UIStatusBarHidden

in info.plist file to hide status bar for ios. Also in my RootViewController.mm is
- (BOOL)prefersStatusBarHidden
{
return YES;
}

to fix hiding status bar on ios7. Everything worked fine untill I tried this code on ios13. At ios13 status bar does not hide anymore. Does anybody know how to hide status bar for ios13?
I also tried to add
UIViewControllerBasedStatusBarAppearance

but nothing seemed to work.

Posts: 1

Participants: 1

Read full topic

[SOLVED] Cmake x86_64 Android problem with PluginIAP

$
0
0

@ComputerDev wrote:

Hello there,
" Starting August 1, 2019, your apps published on Google Play will need to support[64-bit architectures."
So I tried by adding x86_64 to PROP_APP_ABI but I get this error:

Build command failed.
Error while executing process C:\Users\ComputerDev\AppData\Local\Android\Sdk\cmake\3.6.4111459\bin\cmake.exe with arguments {--build C:\Users\ComputerDev\cocos2d-x-projects\Werewolves\proj.android\app\.cxx\cmake\debug\x86_64 --target MyGame}

ninja: error: '../../../../jni/PluginIAP/libs_c++_static/x86_64/libPluginIAP.a', needed by '../../../../build/intermediates/cmake/debug/obj/x86_64/libMyGame.so', missing and no known rule to make it

PROP_COMPILE_SDK_VERSION=28
PROP_MIN_SDK_VERSION=16
PROP_TARGET_SDK_VERSION=28
PROP_APP_ABI=armeabi-v7a:arm64-v8a:x86:x86_64
PROP_BUILD_TYPE=cmake

Posts: 3

Participants: 2

Read full topic

Viewing all 2747 articles
Browse latest View live