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

Get all nodes by name

$
0
0

@hananht wrote:

Hello again,

I am using the following code to get a single node:

const p: cc.Node = cc.find("p");

The problem here that I have more than one node named “p”.
Wht I need is to get multiple nodes by name like this:

const p: Array<cc.Node> = cc.find("p");

Of course this is not working. So how can I achive this?

Posts: 1

Participants: 1

Read full topic


Texture Compression doesnt compress same extension?

$
0
0

@hwiL wrote:

I have very large PNG textures in my project (12 mb). I set up Texture Compression for png with quality 80 and after build it doesnt compress. I dont want compress this texture because then compress in other formats being less effective.
Cocos Version: v2.1.3

Posts: 1

Participants: 1

Read full topic

using template to load scenes...

$
0
0

@digimikeh wrote:

Hi!.
Actually i’m trying to implement inheritance for my scenes, this is a template function member i have in my abstract superclass:

protected:
    template <class T>
    inline void load_scene(T scn, cocos2d::Color3B col) {
        T next_scene = scn::create();
        Director::getInstance()->replaceScene(TransitionFade::create(0.5f, next_scene, col));
    }

Each subclass should load another scene using this function, problem is, it won’t to compile.
C2653 error

I’m wondering if i need to cast something?

Posts: 2

Participants: 2

Read full topic

Forward declaration in Cocos?

$
0
0

@digimikeh wrote:

Hi !, i have created a simple struct that manages some functions for all scenes, some parameters are owned by cocos, so i need to forward declare those types.

#ifndef __HELPER_H__
#define __HELPER_H__

#pragma once

struct Color3B;
class Label;

struct helper {

private:
	const float C_LOAD_SCENE_FADE_TIME = 0.5f;

public:
	template <typename T>
	void load_scene(T scn, Color3B col);	
	void write_text_on_label(Label*& et, const char* txt, Color3B col);
	void play_SFX(const char* sfx_file);
	void play_BGM(const char* bgm_file, bool loop = false);

};

#endif //__HELPER_H__

Then i get the error some incompatible declaration errors, suspect i have not forward declared correctly…

Posts: 2

Participants: 2

Read full topic

Default camera resets its position after TransitionFade to other scene

$
0
0

@digimikeh wrote:

Hi mates…

On init, I set default camera position to ZERO so my viewport is correctly aligned with my sprites, until here all is fine…

When i try to load the next scene using TransitionFade, before this opacity effect begins, the camera position resets to its default value (that is not ZERO),

Director::getInstance()->replaceScene(TransitionFade::create(2.f, scen, Color3B::BLACK));

Posts: 4

Participants: 2

Read full topic

Spine - use transform constraint

$
0
0

@balazsnemeth wrote:

Hi!

We have a Spine animation with some transform constraints. Can we dynamically apply/run these transform constraints runtime from js component files?

I checked the cocos creator spine typescript documentation, but I cannot find any way to apply transform constraints. Also, we do have access to Spine Runtime using getRuntimeData, is there a way to use this to apply a transform constraint?

#spine, #cocos2d-x, #creator

Posts: 1

Participants: 1

Read full topic

Correct way to create a MENU?

$
0
0

@C_Stefano wrote:

Hi, we have a trouble, but we think that we have used badly the UI components in CocosCreators…
We need to open a popup window (as like coins shop, gadget etc…)… but when the node are opened we have always with the background interaction… how to disable this? is there a correct way to create menu in cocos? Now we have generate a cc.Node with inside cc.Button… (and a cc.Sprite for background).

Thanks for help,

Stefano

Posts: 1

Participants: 1

Read full topic

How to use Blend Factors to create the following effect

$
0
0

@hananht wrote:

I am trying to use Blend Modes (NOT MASKS) to create hole in sprite.
For example (I attached an image):

;

The white sprite is the background and the other sprite (the red one) is the Hole that i want to create.
What I need is a transparent area where the hole is standing (I dont want to see the hole at all. I just want to use it to make transparent effect).

Final effect (result):
The red sprite (hole) should disappear and instead we should see the blue/purple background.

Posts: 5

Participants: 3

Read full topic


Orientation issue with cocos2dx 3.17.2 iOS

$
0
0

@frozax wrote:

I have a game which supports portrait and landscape. I can switch from one and the other without issue when the game is running.
However, on iOS, when the orientation changes while the game is not in the foreground, the orientation is wrong when coming back to the game. The reproduction is as follow:

  • Play the game in landscape
  • Tap home and run the Messages application.
  • While in the Mesages applications, go to portrait mode
  • Go back in the game.
  • Observer the problem.

I debugged a little, and discovered that the difference is that resizeFromLayer is not called (from layoutSubviews) when the issue happens.

Any one got an idea to fix it ?

Posts: 2

Participants: 2

Read full topic

RenderTexture used with PolygonInfo renders incorrectly

$
0
0

@MatX wrote:

I want to use a RenderTexture to render some color gradient triangles (before you recommend DrawNode, no, DrawNode is unfortunately not good enough, because I will want to manipulate the RenderTexture by splitting it up into sub triangles, and maybe use some textures). But the below code in my HelloWorldScene that I wrote doesn’t work as expected:

bool HelloWorld::init()
{
    if ( !Scene::init() )
    {
	  return false;
    }

// creating rendertexture
Size size = Size(100, 100);
auto renderTexture = RenderTexture::create(size.width, size.height, Texture2D::PixelFormat::RGBA8888);

// clearing rendertexture with uniform white color
renderTexture->beginWithClear(Color4F::WHITE.r, Color4F::WHITE.g, Color4F::WHITE.b, Color4F::WHITE.a);
renderTexture->end();

// creating triangles to render
auto triangles = new TrianglesCommand::Triangles();
triangles->indexCount = 3;
triangles->indices = new unsigned short[3]{ 1, 2, 3 };
triangles->vertCount = 3;
auto v1 = V3F_C4B_T2F();
auto v2 = V3F_C4B_T2F();
auto v3 = V3F_C4B_T2F();
v1.vertices = Vec3(0, 0, 0);
v2.vertices = Vec3(100, 0, 0);
v3.vertices = Vec3(100, 100, 0);
v1.colors = Color4B::RED;
v2.colors = Color4B::GREEN;
v3.colors = Color4B::BLUE;
v1.texCoords = Tex2F(0, 0);
v2.texCoords = Tex2F(1, 0);
v3.texCoords = Tex2F(1, 1);
triangles->verts = new V3F_C4B_T2F[3]{ v1, v2, v3 };

auto polygonInfo = renderTexture->getSprite()->getPolygonInfo();
polygonInfo.setTriangles(*triangles);
renderTexture->getSprite()->setPolygonInfo(polygonInfo);
this->addChild(renderTexture);
renderTexture->setPosition(Vec2(200, 200));

return true;
}

This gives me the following output:
rendertexture_weird

The problems are:

  • There is no red in it anywhere, however I explicitely specified it. Instead, the bottom left vertex - which should be red - fades into black. Why?
  • The triangle is boxed in a rectangle that is much bigger than 100×100, however I explicitely specified that it should be 100×100.
  • The triangle should have a right angle and the other sides should be of equal length - see the coordinates. But instead, it’s stretched in a weird way when I set the position of the RenderTexture. It should just translate the whole RenderTexture to the specified point. Why is it stretching it, while leaving the bottom left vertex in the origin?

How can I fix all these issues?

Posts: 2

Participants: 2

Read full topic

32 bit apps on new Mac OS Catalina

$
0
0

@piotrros wrote:

Hello,
a bit more of general question, but it’s related to tools like Cocos Studio, but not only that. Is there any workaround to run 32bit apps on the new Mac OS Catalina?

For now I just don’t update, but I’d have to do it in the future. That’s because Apple won’t support older systems for Xcode forever, it’s just a matter of time. I’d like to switch to Creator, but it’s a big task and I also use tons of tools, which runs perfectly fine, but are 32bit only.

Posts: 1

Participants: 1

Read full topic

Android web entering fulllscreen on input

$
0
0

@davidbm wrote:

I’ve set cc.view.enableAutoFullScreen(false); but if I start typing on an Input (the keyboard shows up) and then tap on the game screen (to hide the keyboard) it enters fullscreen automatically.

I’ve tried

var inputs = document.getElementsByTagName(‘input’);
for (var i = 0; i < inputs.length; i++) {
cc.screen.disableAutoFullScreen(inputs[i]);
}

But its still entering fullscreen automatically.

Any thoughts?

Cocos v2.1.3
Google Chrome Android

Posts: 1

Participants: 1

Read full topic

GameJam Devs Build Games For Hobbyist Handhelds

cocos creator axios import

$
0
0

@tdf0495 wrote:

hello im korean developer,

i’m using typeScript

i want to import the axios.js

but problem is import axios from 'axios' is not work!

what should i do?

Posts: 1

Participants: 1

Read full topic

Repeat yoyo (ping-pong) in cc.tween


Facebook plugin gameRequest() and login

$
0
0

@ooleynich wrote:

Hello, I found unpleasant issue on iOS(I have not test it on Android yet).
I call

PluginFacebook::login();

And do successful login(via browser or native facebook app, does not matter), then I call

PluginFacebook::gameRequest("Invite Friends", "Join me");

And see dialog, that ask to login again.

Moreover this dialog don’t allow to use native facebook app to login, just offer to download it(link to App Store), like don’t see facebook app installed on the device.
It is very uncomfortable logic to type facebook login/password instead of login via facebook app.

This behaviour I tested on real devices with iOS 12.4.1 and 13.1. On the simulator I make first login via browser(only way) and then PluginFacebook::gameRequest(“Invite Friends”, “Join me”) don’t ask to login again, just show friends list to invite.

PS I tested this logic on “8 ball pool” game(according to https://www.cocos.com/en/about/ it made on cocos2dx too), and everything is ok: I make login via facebook app, then I invite friends without additional login.

Posts: 2

Participants: 2

Read full topic

cocos2dx framework only have js framework

Second login window when make facebook game request on android

$
0
0

@akargapolov wrote:

Hello!

I use cocos 3.17.2 and 2.5.0.5 facebook plugin.
Login in my facebook account. I can make share without second login, but requests and invites require second login.
This second login window not complied with Facebook Platfotm Policy, and fb reviewer send Warning to us.
Second window similar as right screenshot on link https://developers.facebook.com/policy#7-2-photo

How i can skip second login? Thanks!

Posts: 2

Participants: 2

Read full topic

Undefined symbols for architecture arm64 in cocos 2d-x 3.10 project

$
0
0

@FelixFox wrote:

Hello,

I’m working on an (five years) old cocos2dx project and I’m getting the following errors when debugging for AppleTV
Xcode 11 / tvOS 13 / cocos 2d-x 3.10

Apple Mach-O Linker (ld) Error

Undefined symbols for architecture arm64:
  "cocos2d::TextureCube::create(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&)", referenced from:
      cocos2d::CameraBackgroundSkyBoxBrush::create(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&) in libcocos2d tvOS.a(CCCameraBackgroundBrush.o)
  "cocos2d::TextureCube::setTexParameters(cocos2d::Texture2D::_TexParams const&)", referenced from:
      cocos2d::CameraBackgroundSkyBoxBrush::create(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&) in libcocos2d tvOS.a(CCCameraBackgroundBrush.o)
  "RatingLayer::create()", referenced from:
      ParallaxApplication::createAndShowRatingLayer() in ParallaxApplication.o
  "RatingLayer::acquireBackdrop()", referenced from:
      ParallaxApplication::createAndShowRatingLayer() in ParallaxApplication.o
  "RatingLayer::setReturnCallback(std::__1::function<void ()>)", referenced from:
      ParallaxApplication::createAndShowRatingLayer() in ParallaxApplication.o
  "RatingLayer::hide()", referenced from:
      ParallaxApplication::ratingLayerCallback() in ParallaxApplication.o
  "RatingLayer::show()", referenced from:
      ParallaxApplication::createAndShowRatingLayer() in ParallaxApplication.o
ld: symbol(s) not found for architecture arm64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

The code runs fine on iOS and macOS. This problem appears only on tvOS.
I’m not an experience coder but I know that the guys who build this code were. I’ve been stuck on this for the last two days and I feel I’m missing something stupid.
Any guidance is very appreciated.
Thanks in advance

Posts: 1

Participants: 1

Read full topic

Undefined when loading script

$
0
0

@C_Stefano wrote:

Hi guys, little question:
we have created a class from cc.Component

cc.MapNodeRef = cc.Class({
extends: cc.Component,

properties: {
    prev: {
        default: null,
        type: cc.Node
    },
    next: {
        default: null,
        type: cc.Node
    },      
    sprite: {
        default: null,
        type: cc.Sprite
    },
    id: {
        default: 1
    }
},

onLoad() {
    this.sprite.active = false;
}

});

and we used this class inside another class as like here:

cc.Class({
extends: cc.Component,

properties: {
   
   nodes: {
       default: [],
       type: [cc.MapNodeRef]
   }
},

});

after this, we have this ‘warning’:

The ‘type’ attribute of ‘mapManager.nodes’ is undefined when loading script.

Is it a trouble have this ‘warning’ when we release the game?

Thanks for help,

Stefano

Posts: 1

Participants: 1

Read full topic

Viewing all 17088 articles
Browse latest View live