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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T04:21:05+00:00 2026-06-12T04:21:05+00:00

I am trying to dynamically change the width and height of a Sprite object,

  • 0

I am trying to dynamically change the width and height of a Sprite object, which is a container for other similar Sprite objects. The container object automatically changes it’s size according to the size of it’s children, but when I change the position of the children objects, the size of the container stays the same and it’s children appear to be placed outside of the container.

I tried to solve this problem by using something like this:

if (container.width < (child.x + child.width))
{
    container.width = (child.x + child.width);
}

But when I use this code, the container object’s children are scaled.
Is there a way to change the container’s size without scaling it’s children?

  • 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-12T04:21:06+00:00Added an answer on June 12, 2026 at 4:21 am

    That’s not possible directly, the size of a sprite depends on the bounds of its contents. So the only option would be to resize a child of the sprite, or place a dummy child on x: 0, y: 0 (assuming this would be your desired anchor point).

    The coordinates of the contents bounds is not taken into account as you might expect, when having for example one child that is 100 x 100px, placed on x: 50, y: 50, the parents size would still be 100 x 100px, not 150 x 150px.

    Adding another child of 100 x 100px on x: 0, y: 0 would increase the bounds to 150 x 150, because it now starts on child one x: 0, y: 0 and ends on child two x: 50, y: 50 + 100 x 100px.

    content bounds

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to dynamically change the height of a div container based on the
I am trying to change the button size dynamically, but after using setWidth() and
i'm trying to change the Text on the BUTTON dynamically which is in the
My question is very simple, I'm trying to dynamically change the width of this
I am trying to change my inner div's width dynamically on the click that
Hai am trying to add the height and width of swf dynamically but i
I'm trying to dynamically change a backgroundcolor in a part of a listview, I
I am trying to change the checked attribute of dynamically created html radio button
I am trying to change the text color of a button(api: Button) dynamically, but
I hava a JFrame with multiple JPanels of similar width aligned one below other.

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.