Stack Exchange Network

Stack Exchange network consists of 175 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

Questions tagged [inheritance]

In OOP, this refers to a lower-level class using the definition for a higher-level class' methods or properties.

0
votes
0answers
69 views

c++ character derive from super class [on hold]

I'm trying to create a derived class Warrior from super class Hero instead of using the same ...
1
vote
1answer
35 views

XNA: Classes with Texture2D to be treated as one

Summarised Problem: I have an Animation class that I want to be able to treat as a Texture2D field when need be. I do not ...
0
votes
1answer
21 views

Interact with inheriting class methods from “casted” base class (collisions, etc)

I want to implement a damage system that works across both living items (Entity) and environment items (Environment). The key ...
0
votes
1answer
1k views

Base class undefined?

I have no idea why I'm getting this error except that it has to do with the includes. Base class header file: ...
0
votes
1answer
37 views

C++: Setup the basic Update function in different classes which all derive from GameObject

Im working on a little game-framework in c++. Currently i have a (base)class called "GameObject" from which all future in-game objects will derive from. Class enemy will be ...
1
vote
1answer
83 views

Use GKEntity's component(ofType:) with inheritance

I'm writing a SpriteKit game in swift and making use of GameplayKit's entity-component system. There are many components that do different stuff but share the same methods in which they do it, so I ...
1
vote
1answer
168 views

RPG Item Design [duplicate]

I'm currently fiddling around with some RPG mechanics and I'm trying to implement a solid way to handle items that have different on use effects. Currently, I have a base class called "Item" that ...
0
votes
1answer
40 views

Java: Updating entities in composite design

I'm trying to move beyond inheritance based design, but I've been doing it like that for 6 years. My current hurdle is this: What's the simplest( or proper) way to update all my objects? Before, ...
2
votes
1answer
98 views

Does abstraction influence performance?

Say I have a GameObject class that is being extended by all of the objects in the game that are moving around. (This class provides basic stuff like a sprite, draw ...
1
vote
1answer
421 views

How to expose a child node’s texture from the parent in Godot

I built a simple scene that I instanciate at will. Simply a KinematicBody2D as root, containing a Sprite and a ...
0
votes
1answer
50 views

How to use base.Function() in Unity

I am using 3 classes: EnemyBullet : MonoBehavior EnemyBulletType1 : EnemyBullet EnemyBullet Class: ...
2
votes
1answer
261 views

Instantiating, Inheritance, Objects and Children basics in Unity

First off, please understand I am horrendously confused with how to do things in Unity. I might not even be asking the right questions, I'll pose my problem and hope it shows my gap in knowledge. For ...
0
votes
1answer
106 views
3
votes
1answer
116 views

What is the best practice for creating a system of platforms that does not use Unity's tag system?

Right now I'm finalizing my character raycast controller, but have come to the realization that Unity's tag system, which I'm using as a way for my raycasts to detect different types of platforms, is ...
0
votes
1answer
53 views

Unitys [SerializeField] and parallel inheritance

I have the following: ...
0
votes
1answer
498 views

Cannot implicitly convert type object[] to UnityEngine.GameObject[]

So, I cannot implicitly convert type object[] to UnityEngine.GameObject[]. But why? As far I know, are all types a inheritanced types of object. So, for my logic, I could put a GameObject array in a ...
0
votes
1answer
88 views

How to make Scriptable Objects derive from other Gameobejcts?

I encountered a problem where I want to make a Scriptable Object that derives from another class, but C# does not support multiple inheritance. Further, I do not think it would not make sense to make ...
0
votes
1answer
249 views

SFML Animation class as a strategy or an inheritance

everybody. I need to add animations to my game. And I have a question. I found AnimatedSprite class on SFML Github which is an inheritance, but in my project, I am using a lot of elements made with ...
0
votes
3answers
576 views

How do I switch between different Update behaviour states in Unity?

I have a bird entity that needs different update rules when it's moving or dying (among potentially other states). I want to avoid making my Update method a ...
6
votes
2answers
578 views

Polymorphism vs cache-friendliness

How can we combine inheritance-based polymorphism with spatial cache friendly data structures? In a simple game engine we usually have some base Entity class which is inherited from to implement the ...
4
votes
1answer
156 views

Does interfacing not work as well when it comes to games development?

I'm currently at the start of a project, and I'm following the wisdoms of my day-to-day career as a C# developer for large web applications. Currently I have set up a bunch of interfaces. Notable of ...
0
votes
2answers
199 views

How to optimize classes

I am currently working on a game based on SFML and written in C++. For the HUD of the game I have a HUD class with a lot of different variables and methods. Basically most of the variables have a set ...
0
votes
1answer
377 views

C# What is the advantage of using interfaces for simulating multiple inheritance? [closed]

Interfaces are a feature of C# that I've never quite been able to see the purpose of. I see them used all the time in professional code, but for the life of me I can't work out the reasoning. My ...
3
votes
1answer
182 views

how to make weapon charge up behavior using composition

I am trying to design different weapon behaviors. Right now, there are 3 different types of weapon behaviors that i would like to implement. When not pressing anything, weapon fires at a ...
1
vote
1answer
63 views

Deriving from base class but not calling base method

I am very new to C#, XNA, and OOP. This is my question: I have an abstract class called Sprite. Sprite handles position and drawing from the sprite sheets, from its update and draw methods, for my ...
1
vote
1answer
214 views

Categorizing Projectiles in an arcade shooter (multiple inheritance?)

I have been working on a simple arcade shooter in Java in the vein of missile command/space invaders. I've made a base Projectile class and have been extending other Projectile types from it. This ...
1
vote
0answers
898 views

Making unity inspector accept classes that inherit from a base class

I have a base class that has a lot of classes inheriting from it, I want to make a script that you can drop one of these derived classes into. How do i do that? ...
0
votes
2answers
549 views

What if I extend a uclass without UClass() in Unreal Engine?

What happens if I extend a uclass (or UObject) without the UClass() macro? Will it still be a UClass() and managed by the garbage collector? I'm just curious. Update I managed to extend ...
0
votes
2answers
153 views

How do i approach these inheritance problem? (Pokemon Gen III) [closed]

I'm currently making a Pokemon clone on Python just for the heck of it. After fiddling a bit with some GBA ROM editing tools, i've found out that on these games there are, among other things: Events ...
0
votes
1answer
2k views

Error : No default constructor exists for “Sprite” [closed]

What i want to do is make the Player class inherit the Sprite class. So I inherited it like this : class Player: public Sprite {}; But when I go to my Player....
1
vote
1answer
180 views

Inherited property in derived class reference only base class

[Context] I am developing a game in Unity, and wanted to make a Game Manager. Like many examples out there, it uses a Singletron design pattern. But i have several other Managers, all using Singletron ...
0
votes
2answers
445 views

Problem designing my pseudo-3D game with SFML

I am designing the game so the objects I create (Character, Enemy, Enemycast...) can inherit all from Collider SpineDrawable // Sprite // AnimatedSprite D2D // D3D Both D2D and D3D inherit from <...
1
vote
0answers
75 views

Java (libGDX) - Inheritance problems

I'm having some issues with inheritance for one of my libGDX projects, I'm making a game similar to (very stripped down) Terraria or Starbound and I am using the TiledMap to load the world, ...
3
votes
2answers
404 views

Space game: inheritance for spaceships?

In a space game I'm writing in C++11, I have a class Spaceship. Now I want to create 3 more spaceship types, how should I do? Attack type: have a weapon ...
4
votes
3answers
964 views

Callback on Derived Class?

How does Unity3D implement their system where if a class is derived from MonoBehaviour and has certain methods like Awake() or Update(), they are called accordingly? I want to do a similar system for ...
0
votes
1answer
217 views

Have several classes with a common interface, but still able to access MonoBehaviour methods through that interface?

In our project we used to have a PlayerObject class and then Unit and Building derived from that class. We recently started taking a look at Bolt, which requires classes that define objects that may ...
0
votes
1answer
189 views

Weird inheritance hierarchy?

In my RPG, all Food objects should be possible weapons. For instance, I want the player to be able to to try kill bunnies with a cherry or a watermelon. The problem is that the easiest way to do this ...
0
votes
1answer
53 views

How to reuse code [closed]

I have three classes. Monster derives from Animation. Animation derives from Collider. This is, monster is an animated collider. However, I'd like to have animated objects that are not colliders. ...
0
votes
1answer
673 views

How does super.render() call this method?

Today I was experimenting with adding different screens with Scene2d in libgdx and while doing so I became confused how ...
1
vote
2answers
685 views

Single or multiple inheritance for game world objects

So I am currently laying out on paper the system I want to code for a game in C++. Now currently I am debating whether to have e.g. a class object_door that inherits from another class ...
1
vote
1answer
1k views

Should I use inheritance or interfaces for an inventory system? [closed]

I'm about to start programmin an inventory, harvest and loot system. I will need enemies that drop items, harvestable environmentals that yield resources and an inventory system that takes items and ...
0
votes
1answer
136 views

How to save a character to be used in all Game States?

I am using C# and SFML. I am having a problem understanding how to save a character in memory, so I can use the character in any game state. Right now, the character is a class, and the player ...
1
vote
1answer
692 views

Making specific Enemy Classes

So I was just looking through an old game I had made for android, and was second guessing how I was sub-classing enemy for each particular enemy in my game. My enemy class had all kinds of properties,...
2
votes
1answer
662 views

Spell classes and inheritance

I'm currently developing a small game, that includes spell casting. My class structure looks like this: AbstractSpell AbstractDamageSpell AbstractClickableSpell AbstractClickableDamageSpell "...
1
vote
1answer
366 views

How to use/apply class inheritance in Enchant.js

You're developing a game using Enchant.js and you just need an Enemy class which multiple enemy classes derive from and every enemy has its own sprite and stuff.
4
votes
2answers
568 views

Game state management: the buck doesn't stop “here” soon enough

I realize there are already many Q&As on this site about GameState/GameScreen management, state machines, state stacks, etc. This question is meant as a follow-up: Suppose hypothetically I ...
6
votes
2answers
4k views

How should I plan the inheritance structure for my game?

I am trying to write a platform shooter in C++ with a really good class structure for robustness. The game itself is secondary; it is the learning process of writing it that is primary. I am ...
2
votes
1answer
2k views

Custom inventory items based on inheritance

So, here's the scenario: I'm building an RPG. Like most of the other RPGs on the market, my game will feature an inventory and of course, inventory items. So far I've worked well with using a single ...
9
votes
2answers
955 views

Doesn't multiple inheritance solve all problems that entity systems do?

The question is pretty self explaining: doesn't multiple inheritance solve all the problems that entity systems also solve? I just remembered a term called "multiple inheritance", and that seems to ...