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 7653307
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T11:59:56+00:00 2026-05-31T11:59:56+00:00

I am in process of making a small game, where the main Gameplay Layer

  • 0

I am in process of making a small game, where the main Gameplay Layer is being zoomed in and out based on a number of parameters. This is done by setting the .scale attribute to a fraction of 1. Works well.

I have a problem, however, that when calling [[CCDirector sharedDirector] winSize]; from any of the child nodes, I get a scaled window size, which kinda sucks 🙂 Is there any way around this apart from multiplying all my off-screen checks by the scale fraction plus one?

Here is an example

I am creating a CCLayer and placing Sprites on it. All the sprites have a static variable with the screen size during initialization, basically

static CGRect screenRect; //stored as a static variable for performance reasons
...
-(id)init{
    ...
    // make sure to initialize the screen rect only once
    if (CGRectIsEmpty(screenRect)){
        CGSize screenSize = [[CCDirector sharedDirector] winSize];
        screenRect = CGRectMake(0, 0, screenSize.width, screenSize.height);

        CCLOG(@"Screen Size during init: %f, %f", screenSize.width, screenSize.height);
    }
}

I then have a check when the sprite is moving around whether it is off the screen, and if so, I take it automatically to the opposite side:

if(newPosition.x > screenRect.size.width){
    newPosition.x = 0;
}else if(newPosition.x < 0){
    newPosition.x = screenRect.size.width;
}

if(newPosition.y > screenRect.size.height){
    newPosition.y = 0;
}else if(newPosition.y < 0){
    newPosition.y = screenRect.size.height;
}

All works very well and as expected. However, if I change the scale property of the parent CCLayer then offscreen positioning “scales” together with the layer, which is kinda weird. So if I set the CCLayer.scale = 0.5f; then it appears as though the off-screen boundaries have moved “inside” the phone screen as well. I want to avoid this. How?

  • 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-05-31T11:59:58+00:00Added an answer on May 31, 2026 at 11:59 am

    After talking to quite a few developers, the off-bounds check need to take scaling into account, i.e.

    newPosition.x > screenRect.size.width/CCLayer.scale
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm in the process of making a browser based multiplayer turnbased strategy game similiar
I'm in the process of making a simple Todo List application based on Joosy
I am in the process of making a small program that reads a file,
Good afternoon. I have been making a small openGL based app for android that
I'm looking for a really really small linux distribution or process of making my
I'm making a small card game on iOS. I'm using GameKit/GKsession to handle my
I've written a small 2D engine in opengl in the process of making a
I'm in the process of making a small query thing for a set of
Our build process constructs several products out of a relatively small set of plugins.
In the process of making an old webpage standard compliant, the validator came across

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.