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

Android DPI and screen width/height still wrong

$
0
0

@gmayer wrote:

Hello.
There are a few threads about issues getting screen size and DPI on Android.

Here is an issue from 2017 that appears to be still open.

In addition to the wrong DPI, I’m not even getting the correct width and height for my device.

Samsung A8 - from Droid Info app, the internet, and screenshots, my device is
2220 x 1080 (landscape width + height)

The following calls in code:

	float width = director->getWinSize().width;
	float height = director->getWinSize().height;

	Size sizeInPixles = director->getWinSizeInPixels();

	Size visibleSize = director->getVisibleSize();

all give me 1665 x 810

Also,

float dpi = (float)(Device::getDPI());

reports 360, when it should be 480.

The situation is somewhat better on iOS. iPad3 and iPhone5s give correct width, height, and dpi, but iPad Mini (original) has correct width, height, but WRONG dpi – this makes the calculation for screen size give a result almost the same as a 9.7" screen, instead of the 7" it actually is.

I saw this workaround for Android dpi:

but that appears to be java code. Not sure how to expose that to C++.

Could this be fixed please!?
I’m on the verge of shipping and important update to my game, and am blocked by this, because there are a few decisions I want to make in code at startup based on physical screen size, but I have no reliable way of doing it!
:frowning:

thanks
Greg

Posts: 1

Participants: 1

Read full topic


Cocos Creator 2.3.1 Error

Shape Slice , Cocos2dx & LiquidFun

Helping people prep for viruses with Cocos Creator

Switching between local videos shows gray/black play button temporarily

$
0
0

@cherryDog55 wrote:

Hi everyone, I’m using Cocos Creator 2.2.0, developing a Roulette game. I’m building as mobile web (therefore the output is html/javascript) and then running the game within a webview on an Android device. I’m seeing a gray/black play button image just before a local video file is played using the VideoPlayer control. This occurs each time I switch to a new video in my game. See attached screenshot for an example. The video files are mp4 and they aren’t that big, 1MB, 2.5MB, and 7.6MB. To start the video player I’m doing the following:

let vplayer = this.videoNode.getComponent(cc.VideoPlayer);
vplayer.clip = this.mainAttractionVideo;
this.videoNode.runAction(cc.sequence(cc.callFunc(vplayer.play, vplayer), cc.delayTime(0)).repeatForever());

and then to transition between videos, I’m changing the clip property to point at the next video asset, like so:

let vplayer = this.videoNode.getComponent(cc.VideoPlayer);
vplayer.clip = this.spinStartVideo;

please let me know if you have any ideas on what I can try to avoid the temporary “play” image from showing. It happens even when showing the initial video.

Posts: 1

Participants: 1

Read full topic

[Cocos2d-x] How to send object from Scene to Scene via Notification Center

$
0
0

@joelam500 wrote:

Dear all,

I am trying to send the object of SIOClient from one scene to other scene. After implemented the code below, I emit an event at HelloWorld side but I got the bad access error at SIOClient in HelloWorld.

Am I did something wrong below? Please HELP!!!

First Scene

// SIO connect
_sioClient = SocketIO::connect( "25.0.126.193:3000", *this); //223.16.193.48 25.0.126.193
    
// Send sioClient to NC
PostMessage(_sioClient);

void AppDelegate::PostMessage(cocos2d::Ref* pSender)
{
    __NotificationCenter::getInstance()->postNotification("getSIOClient", _sioClient);
}

Second Scene

// Get SIOClient from Notification Center
__NotificationCenter::getInstance()->addObserver(this, callfuncO_selector(HelloWorld::getMessage), "getSIOClient", NULL);


void HelloWorld::getMessage(cocos2d::Ref* pSender)
{
    _sioClient = (SIOClient*)pSender;
}

Posts: 1

Participants: 1

Read full topic

LNK 2019 error when i create a new scene. WIN32

$
0
0

@rdv3736 wrote:

Whenever i try to call the create() function included in cocos2d I get a LNK2019 error Severity Code Description Project File Line Suppression State
Error LNK2019 unresolved external symbol “public: static class cocos2d::Scene * __cdecl startScene::createScene(void)” (?createScene@startScene@@SAPAVScene@cocos2d@@XZ) referenced in function “class cocos2d::Scene * __cdecl createScene(void)”

My code for the new scene is:
Header file:

      #ifndef __START_SCENE_H__
     #define __START_SCENE_H__
 
     #include "cocos2d.h"
 
     class startScene : public cocos2d::Scene
     {
     public:
     	static cocos2d::Scene* createScene();
 
     	virtual bool init();
     	void menuCloseCallback(cocos2d::Ref* pSender);
 
     	CREATE_FUNC(startScene);
     };
 
     #endif

My CPP file:

#include "startScene.h"

cocos2d::Scene* createScene()
{
	return startScene::create();
}

bool startScene::init()
{

	return true;
}


void startScene::menuCloseCallback(Ref* pSender)
{
	cocos2d::Director::getInstance()->end();
}

Posts: 3

Participants: 2

Read full topic

Turbo Machine ! Fun racing game :)

$
0
0

@tranthor wrote:

Wohoo!!
I released the first version of my new game: Turbo Machine (developed in cocos2d-x 3.17)
:star_struck: :star_struck: :star_struck:

Features:

  • Simple two-finger controlling mechanics, designed for touch screens
  • More than 50 funny levels
  • 11 game modes (per time, per fuel, dodge obstacles, collect stars, and more!)
  • Daytime, nighttime, rainy, snowy levels, and more!
  • 6 types of cars to choose from!
  • Available in 2 languages: English and Spanish

Previews:

Links:
iOS: https://apps.apple.com/ar/app/turbo-machine/id1493135781
Android: Coming soon… I’ve some problems in Android that I couldn’t fixed yet (Read this topic for more info: Desynchronisation between frame and physics intervals). Don’t hesitate to help me if you know how to fix it :pray:

Tested in:

  • iPhone 7
  • iPhone 8
  • iPhone 6s Plus
  • iPhone X

Do you have another iPhone? Then, plz, try it and give me your feedback!! :slight_smile:
Comments & suggestions are welcome :smiley: :blush: :yum:

Posts: 2

Participants: 2

Read full topic


How to locate Prefab in script?

$
0
0

@Dban1 wrote:

Hi, i’m making a game with many different hero classes and enemies and I’m thinking of creating a “Prefab bank”. Normally, to instantiate Prefabs you’d have a pointer to the Prefab like cc.instantiate(this.HeroPrefab).

As i have many scenes, i don’t want to have to drag and drop every prefab into the component panel for every time i use the Prefab Bank in a new scene.

So my question is how do i locate the Prefab in the asset panel to fill in the default: field in the component properties?

For example
default: null, type: cc.Prefab

How do i change the default so that the game knows the Prefab to reference?

Posts: 1

Participants: 1

Read full topic

Unable to compile Windows build

Can't build Firebase v2.6.0.1on iOS

$
0
0

@jokerx86 wrote:

When I build Firebase with Xcode 11.3.1 it has this error

Undefined symbols for architecture x86_64:
OBJC_CLASS$_GULHeartbeatDateStorage”, referenced from:
objc-class-ref in FirebaseCore(FIRHeartbeatInfo.o)
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

I used Cocos Creator v2.3.0

Posts: 1

Participants: 1

Read full topic

Cannot visualize special characters as ù and à

$
0
0

@ele_elion wrote:

Hi there,
I’m using c++, in cocos 3.17 on Mac with Xcode. In the beginning, the game was created on cocos 2.2.6. I use a executable for the texts in my game, called Localized_it, and something goes wrong during the porting, because special character as “ù” are not visualized in the text, there is a little square instead. Localized_it it’s exact the same of the old one.

Someone can figure out why?

The file is read as Default - C++ Source and the Text Encoding is Unicode (UTF-8)

Posts: 1

Participants: 1

Read full topic

Cocos2d-x 3.17.1 Editbox SetFocus by Tab key

$
0
0

@MingJiang1988 wrote:

Hello, Im developer on cocos2d.x.
But not so good expert.
I have a problem on cocos2d-x 3.17.1 Lua probject.
My problem is below as:
I have a project with 2 ccui:Editbox.
I want to set the cursor to next Editbox when I click Tab key(on windows platform).
So When I click Tab key, I want to move cursor to other Editbox.
But I can not find solution.

local function key_return(keyCode, ref)
local platform = cc.Application:getInstance():getTargetPlatform()
if cc.PLATFORM_OS_WINDOWS == platform then
if keyCode == 8 then --TAB key
if toFillAcc then
–self.account:setFocused(false)
self.password:setFocused()
toFillAcc = false
else
–self.password:setFocused(false)
self.account:setFocused()
toFillAcc = true
end
elseif (keyCode == 35 or keyCode == 164) then --enter key
onClickLogin(nil, ccui.TouchEventType.ended)
end
end
end

local key_listener = cc.EventListenerKeyboard:create()
key_listener:registerScriptHandler(key_return, cc.Handler.EVENT_KEYBOARD_RELEASED)

local eventDispatcher = scene:getEventDispatcher()
eventDispatcher:addEventListenerWithSceneGraphPriority(key_listener, scene)

This is my code.
I hope solve this soon.
Thanks.

Posts: 1

Participants: 1

Read full topic

Issue with ScrollView

$
0
0

@sethu_gametion wrote:

Hi,
I was a cocos2d-x developer and now trying out cocos creator for my new project. I’m unable to use the ScrollView in horizontal mode but it works fine in vertical mode. I’m working with version 2.3.1. Is anyone else facing the same issue and is there any possible fix for this? Thanks in advance for any help.

Posts: 1

Participants: 1

Read full topic

Cannot re-init Scripting Engine on Android

$
0
0

@sonlehong wrote:

Hi,

I’m doing some customization on Cocos2d-x-lite engine.
I want to re-create Script Engine after destroying it by using codes like:

se::ScriptEngine::destroyInstance();
//doSomeStuff();
se::ScriptEngine::getInstance()->start();

But I got crash at ScriptEngine::init() function:

//....
create_params.array_buffer_allocator = v8::ArrayBuffer::Allocator::NewDefaultAllocator(); //crash here
//... 

It doesn’t happen on iOS, just only on Android because iOS doesn’t use V8 engine.
Does someone have any idea about this issue? I think it relates to V8 engine but I’m not familiar with it, so I can’t figure out the root cause of this issue.
Thanks!

Posts: 1

Participants: 1

Read full topic


Social sahring without using sdkbox?

Android WebView Min Version

$
0
0

@gustn5234 wrote:

Hello.

I have an issue with the Android webview.

Build into Web Mobile and test is in progress through Android webview.

If the OS of the test device is 4.2.2 and 4.4.2, the web view is not running.

From 6.0.1, it was working normally.

What is the minimum OS version of the Android webview?

Posts: 1

Participants: 1

Read full topic

How to keep component collapsed in properties panel

$
0
0

@ratang wrote:

Hello, in Cocos Creator, when I:

  1. Collapse a component in the properties panel
  2. Click on a different Node, opening it in the properties panel
  3. Go back to the first node (with the component I collapsed)

All the components are expanded.
Is there way to save a component’s collapse state?

Thank you :slight_smile:

Posts: 1

Participants: 1

Read full topic

How would you properly size sprites?

$
0
0

@rdv3736 wrote:

Basically, how do i properly size a sprite with pixel sizes so like (16,16) in pixels or (32,32) instead of having to scale the sprite?

Posts: 2

Participants: 2

Read full topic

falling multiple fruits sequentialy into an bucket?

$
0
0

@Chandu8893 wrote:

i wrote code single ball fall into bucket. but i have a logical error to fall multiple balls into bucket and add score? help me guys

whiteeggball: {

        default: null,

        type: cc.Node

    },

    whiteeggballprefab: {

        default: null,

        type: cc.Prefab

    },

    bucketone: {

        default: null,

        type: cc.Node

    },

    buckettwo: {

        default: null,

        type: cc.Node

    },

start () {

    cc.log('whiteeggball pos');

    this.xSpeed = 500;

    

},

 update (dt) {

    this.whiteeggball.y -= this.xSpeed * dt;

    cc.log('whiteeggball pos' + this.whiteeggball.y);

    
   

 },

Posts: 1

Participants: 1

Read full topic

Viewing all 17119 articles
Browse latest View live


Latest Images

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