How to reduce amount of layers & 'duplicate' objects

Get help using Construct 2

Post » Tue Mar 10, 2015 1:47 pm

Hello,

I am making a small tycoon game, where you can buy land and build homes on them. Also, you can sell or rent out the homes. Now I was wondering how does one handle all this? Forgive me for asking such a broad question, but what I have for example is this (which appears to be totally futile);

Futile.jpg

Problem is that I am getting the idea that I will need to be creating dozens of layers, since each lot could potentially have a different type of home and will each need a unique menu to set the rent and sale price.

If anyone could point me in the right direction, perhaps even to relevant assets on the Scirra store, or tutorials or otherwise help me out, that'd be fantastic. I finished all of the artwork for the game, now I just need to get the back end working.

Thanks in advance for any help.
You do not have the required permissions to view the files attached to this post.
B
13
S
7
G
4
Posts: 143
Reputation: 3,581

Post » Tue Mar 10, 2015 1:51 pm

Different homes:

create a sprite with all the homes: each frame being a different home, instead of layering, refer to the correct frame for the home needed to be displayed.


And for menus, just create them when needed and destroy when done :)
Who dares wins
B
57
S
17
G
21
Posts: 1,878
Reputation: 19,572

Post » Tue Mar 10, 2015 3:52 pm

Thanks for your reply.

I've put the homes in one animation, but am running into problems creating and destroying buttons. See, I have an event where I create a buy button when a vacant lot is clicked. However, if you click the vacant lot twice in a row, it'll create two buy buttons overlapping eachother. How do create only one buy button when the lot is clicked? Or some other way.

I tried for each, but that doesn't work for the game, I'd like the player to be able to go back to the vacant lot and click it again, only without creating the buy button over and over again.
B
13
S
7
G
4
Posts: 143
Reputation: 3,581

Post » Tue Mar 10, 2015 3:59 pm

Add a boolean check, created, to the clikcable vacant lot.

event
On clicked vacant lot
boolean vacant.created (inverted)
action
vacant.created = true
and rest of your actions
Who dares wins
B
57
S
17
G
21
Posts: 1,878
Reputation: 19,572

Post » Tue Mar 10, 2015 4:52 pm

Thanks for your reply, I wasn't familiar with booleans yet, it worked real nicely!

Now I'm just facing the issue where I am selecting between different lots. For example, if I click on vacant lot 1 and then vacant lot 2, the buttons stack from each lot. If you press the buy button they both disappear and two times the appropriate amount of cash is subtracted. So what I need is only one lot to be 'selected' at the same time. I suppose I could destroy all buttons but that one, but even with families seems like a heck of a task which I can't really figure out how to handle.

Or, perhaps use variables to check whether a lot is selected, but it seems like one will end up with 30 (amount of lots) variables per event.

Here's what I got:

1.jpg
You do not have the required permissions to view the files attached to this post.
B
13
S
7
G
4
Posts: 143
Reputation: 3,581

Post » Tue Mar 10, 2015 6:50 pm

nah, not 30, just a couple.

I would use an instance var to determine which, and use systems pick by comparison to pick the needed one.
Who dares wins
B
57
S
17
G
21
Posts: 1,878
Reputation: 19,572

Post » Wed Mar 11, 2015 12:39 pm

read in the manual about: function()
B
15
S
4
Posts: 77
Reputation: 1,030

Post » Wed Mar 11, 2015 5:53 pm

@lennaert Allright so I add for example 'Selected' as an instance variable to two lots. Then add as a condition pick by comparison to Lot1?, 'Lot1.Selected', but what do I enter as the value? I'm trying to figure out how to implement this in the code I have above, but am unable to figure it out, how would you structure the code?

And do I also still need to use global variables with this?

@edwardr Yeah I read about functions, and wanted to apply it, but Lot1 and Lot2 need to do everything differently (using the next number in line every time) so I don't see how I could use functions to overcome duplicating groups and replacing the objects with the next number in line.

I searched the web and Scirra's store for examples of simulating menus/selections, but didn't find anything that resembles what I want to make. Would be great also if someone could point me in the direction of learning what I'm trying to make!

In any case, thanks for your help so far.
B
13
S
7
G
4
Posts: 143
Reputation: 3,581

Post » Wed Mar 11, 2015 7:06 pm

I would use as many instance variables to objects as possible.

The names can be whatever you want ...

example

sprite Slots

slots.active = false
slots.slotnum = 1
slots.item = url

slots.active = false
slots.slotnum = 2
slots.item = url


event
on click slots
sub
slots.active false (inverted)
action
set slots.active true
sub (to slots active false)
slots.slotnum = 1
create button on x,y
sub (to slots active false)
slots.slotnum = 2
create button on x,y
Who dares wins
B
57
S
17
G
21
Posts: 1,878
Reputation: 19,572

Post » Wed Mar 11, 2015 11:54 pm

ok not knowing the program, I programmed a small sample.
here a small description:
I add the images into a family, add a family variable (right click), click each image in the family and name it.
Now you know which image/lot will be clicked.

I include 3 version (put you also can do this in one function, but this will be more difficult to understand):

a.) showing the image name (the ID)
the command function.param(0) use the variable within the function. It is passed when you call it (you can add several param and use it with function.param(1)

b.) compare variables
when this variable is clicked do this,.... when this clicked do this...

c.) calculation
you can also calculate or do other stuff. Not just showing text

you can also combine it
You do not have the required permissions to view the files attached to this post.
B
15
S
4
Posts: 77
Reputation: 1,030

Next

Return to How do I....?

Who is online

Users browsing this forum: jezjones24, Yahoo [Bot] and 23 guests