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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T05:23:01+00:00 2026-05-27T05:23:01+00:00

I have an image I’m trying to use as a background in Android. The

  • 0

I have an image I’m trying to use as a background in Android. The image is tablet sized, but I’d like it to scale down when there is a smaller screen. I know the aspect ratio might be off. In any case, here is my code:

CGSize winSize = CCDirector.sharedDirector().displaySize();
    Log.v("MP", "Width: " + winSize.width + " Height: " + winSize.height);
    CCSprite backGround = CCSprite.sprite("background1.png");
    this.setIsTouchEnabled(true);
    //backGround.setContentSize(winSize);
    backGround.setScale(.5f);
    backGround.setPosition(CGPoint.ccp(winSize.width/2.0f,winSize.height/2.0f));
    addChild(backGround);

What is happening is my image is not being scaled down automatically. So you’ll notice here i’m setting down the scale. .5 is an arbitrary value for testing. I’ve noticed that the graphic does scale down when I do that, but my image is cut off. It only shows the top left corner of the image.

Perhaps someone can help me with this problem and also give me some general advice on supporting multiple screen resolutions on Android with Cocos2D. I know how to handle this problem without using Cocos2D, but am still learning Cocos2D and am unsure of what to do.

  • 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-27T05:23:02+00:00Added an answer on May 27, 2026 at 5:23 am

    that is a hard issue; we usually use this method:

    background.setScaleX(winSize .width/background.getTexture().getWidth());
    
    background.setScaleY(size.height/background.getTexture().getHeight());
    
    background.setPosition(CGPoint.make(size.width/2, size.height/2));
    
    addChild(backGround);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

So I have Image like this (source: de-viz.ru ) I want to get something
So I have Image like this (source: de-viz.ru ) I want to get something
I have image with some object at not solid background. I want to extract
I have image map like this <map name=imgmap> <area shape=poly coords=63,10,64,38,89,37,91,10 href=# id=x1></map> and
I have image URLs like http://example.com/someimage.png - how do I fetch that image and
I have image that needs to be scrolled in uiscrollview but scrolling needs to
I have image (500x500) but I need to resize it to 200x200 and paint
I am trying to have image column headers in my grid. They sort of
In Interface Builder I have this hierarchy: View 1.1 Image View //it's my background
I have image background.jpg as the background. Every 10s, how to load a new

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.