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

  • Home
  • SEARCH
  • 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 8797633
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T23:53:34+00:00 2026-06-13T23:53:34+00:00

I have a class that needs to use the graphics methods of the Sprite

  • 0

I have a class that needs to use the graphics methods of the Sprite class, so I’ve extended said class using Sprite. However I have my own custom class that the first class ALSO needs to extend from to use the properties and methods written within.

Of course I could extend my custom class by Sprite and the first class would be able to use both, but my custom class has nothing to do with Sprite and shouldn’t extend it.

How would I go about using the properties and methods of my custom superclass AND use the graphics properties of the Sprite class in one subclass?


My simple example:

My custom class is named MovingObject.as and contains two variables and some methods that need to be inherited by a subclass. The purpose of MovingObject is to hold information relating to the speed and acceleration of their child classes.

The child class ‘RaceCar’ is drawn using the graphics methods given by expanding Sprite, but I need to expand from MovingObject allowing the RaceCar to inherit speed and acceleration.

I’m stuck on how to both give RaceCar the features of expanding from Sprite and my MovingObject class.

  • 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-13T23:53:36+00:00Added an answer on June 13, 2026 at 11:53 pm

    If your first class needs to be added to the display list it should almost certainly extend Sprite. How you make the functionality of your second custom class available to it will probably depend on what that functionality is (if you could give a brief description it would make answering the question much easier).

    However, in addition to extension (which you’ve ruled out), I can think of two other methods:

    1. Give your first class an instance of your custom class to act on either through a setter or by instantiating the custom class directly in your first class. This is known as composition.
    2. Make the methods on your custom class static so that they can be called by your first class without instantiating it. This is a method typically used for utility type classes.

    Update:

    I think you might be complicating things unnecessarily in this case, unless you envisage having sub-classes of MovingObject which are not visually represented on screen (which seems unlikely to me). If not, it’s perfectly valid for MovingObject to extend Sprite, in effect augmenting it with moving functionality, and this forming the base class for your RaceCar (and any other moving, visible objects).

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

Sidebar

Related Questions

I have a class that needs to be initialized but it's namespaced like this:
I have a generic class that needs to limit an enum depending on the
I have a Base class that needs a Generic type. That can be either
I have a utility class that needs to work on a generic Class but
I have a situation where I have an instanced class that needs to call
I have a non-Activity class (let's call it NonActivity) that needs to post a
If you have data for a class that will be modified and needs to
In Python, say I have some class, Circle, that inherits from Shape. Shape needs
I have a program that needs to use sleep. Like really needs to. In
I have a class that needs to get some settings from the application configuration

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.