Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8731593
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T09:16:26+00:00 2026-06-13T09:16:26+00:00

I came into a trouble with cocos2d-x, which I may not be able to

  • 0

I came into a trouble with cocos2d-x, which I may not be able to solve alone, therefore I’m asking for your help. I wanted to create my own CCScene with CCLayer -as part of my cocos2d-x learning. Everything is working fine, except the size of the scene. CCDirector::sharedDirector()->getWinSize() report totally messed up resolution, like 0 x 108134400… and I don’t know what I’m doing wrong.

Here is my class

.h
#pragma once
#include "cocos2d.h"

class zfGameScene : public cocos2d::CCLayer
{
public:
    static cocos2d::CCScene* scene();
    virtual bool init();
    CREATE_FUNC(zfGameScene);
};

Aaaaand

.cpp
#include "zfGameScene.h"
#include "cocos2d.h"

using namespace cocos2d;

CCScene* zfGameScene::scene(){
CCScene * scene = NULL;
    do 
    {
     scene = CCScene::create();
        CC_BREAK_IF(! scene);

        zfGameScene *layer = zfGameScene::create();
        CC_BREAK_IF(! layer);

        scene->addChild(layer);
    } while (0);

    return scene;
}

bool zfGameScene::init(){
    bool returnValue = false;
    while(!returnValue){
        CC_BREAK_IF(!CCLayer::init());

        // This one is for loading the scene :P
        CCSize winSize = CCDirector::sharedDirector()->getWinSize();
    CCLog("[zfGameScene] Initialising with %d x %d...", winSize.width, winSize.height);

        CCSprite *background = CCSprite::spriteWithFile("background.png", CCRect(0, 0, 2048, 1536));
        this->setScale(1);
        this->setPosition(ccp(0, 0));
        this->addChild(background);

        returnValue = true;
    }

    return returnValue;

}

Thanks in advance for your help.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T09:16:27+00:00Added an answer on June 13, 2026 at 9:16 am

    Width and height are float. Just change your code like this:

    CCLog("[zfGameScene] Initialising with %f x %f...", winSize.width, winSize.height);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm using SVN (TortoiseSVN) and often came into the following situation: I wanted to
I am developing a webpage but I came into some trouble with some javascript
I came into matrix world from loop world (C, etc) I would like to
Since the GOF book was put together well before .Net came into being, are
I was experimenting jMock as my mocking framework for my project. I came into
I came across this problem when trying to decode json into an array ,
I was doing some research into general topics of software engineering and I came
I came across a table of freq. counts today I had to expand into
I'm trying to convert come vb.net code into C# but came across optional in
Recently I ran into trouble when I discovered that vista restricts what can be

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.