Inheritance Problem again...

Get help using Construct 2

Post » Thu Mar 06, 2014 9:12 am

Hi guys,

I'm really unhappy with the structure of families in construct and try to think of a better way to handle this issure, since I have a lot of class inheratance. I've made up an example, which hopefully make you understand my problem. Let's assume the atachment is my class model and I create one family for each class. (I love car examples :) ).
Imagine one day a costumer comes to my vehicle rental agency. His requirements are:
- He wants a land vehicle
- All motorcycles should be in first row
- all trucks should be in last row
- When he clicks on a motorcycle show me the horsepower

This is what I would do:

Pick all vehicles
---Foreach Vehicles
---LandVehicles = Vehicles.UID
-------Show LandVehicle
------Foreach LandVehicles
------Motorcycles = LandVehicle.UID
----------Put motorcycle in first row
------Foreach LandVehicles
------Trucks= LandVehicle.UID
---------Put truck in last row

On click Motorcycle
Vehicle = Motorcycle.UID
---show Vehicle.horsepower

Is there any better solution? I mean there are a lot of foreach loops. And the biggest problem: I can't even access my instance variables from other families. For example horsepower is an attribut that's shared by all vehicles. But when I click on a specific vehicle I always have to reference to the family.
You do not have the required permissions to view the files attached to this post.
B
14
S
3
G
1
Posts: 255
Reputation: 2,027

Post » Thu Mar 06, 2014 9:38 am

Where you storing the horsepower?

My thoughts, is use instance variables.

Will try to do demo...

Here you go, its not the best way, but I just made a whole keyboard input system yesterday doing this way and worked FANTASTICLY well. Upercase, lowercase etc (for mobile devices so we can drop the TextBox all together :)
You do not have the required permissions to view the files attached to this post.
You think you can do these things, but you can't, Nemo!
Just keep reading.
Just keep learning.
B
65
S
16
G
9
Posts: 1,429
Reputation: 12,708

Post » Thu Mar 06, 2014 9:46 am

@Rabenmutter,
So now it is 1 check if you require it - using instance variable "Type", but you can add more instance variables to check.

You can use foreach vechiles
And put conditions in based on instant variables.

So many options, and no real right way to do someting lol.

Oh, I'm not using families at all here. But you can use them to if you want.
You think you can do these things, but you can't, Nemo!
Just keep reading.
Just keep learning.
B
65
S
16
G
9
Posts: 1,429
Reputation: 12,708


Return to How do I....?

Who is online

Users browsing this forum: No registered users and 18 guests