How do I Building mechanics

Get help using Construct 2

Post » Sun Mar 06, 2016 9:26 pm

Message: ElChuchis can only post plain text URLS until they have 500 rep. 1 URLS modified. Why?
Hello lovely community of game developers!
I am finding for help, I have this:

2 sprites:
Tent roof
Tent floor

When i create the full building in specific layer, if i want to create a new other tent building, the previous one disapear. I can't use for each because an error appear.

CHECK HERE:
https://gyazo.com/c7683e89b40586df6faad5efa8418404

Thanks youuu all for reading my question!!!!
:D
B
14
S
6
Posts: 63
Reputation: 1,236

Post » Mon Mar 07, 2016 5:01 am

I'm going to guess that the previous instance isn't disappearing, but after you make a new instance, both of them get set to the exact same spot.

What is the purpose of the second event running every x seconds? This is what is causing all the instances of your tent objects to be set on the same spot.
Mistakes were made.
B
54
S
28
G
115
Posts: 1,705
Reputation: 65,083

Post » Mon Mar 07, 2016 10:25 am

oosyrag wrote:I'm going to guess that the previous instance isn't disappearing, but after you make a new instance, both of them get set to the exact same spot.

What is the purpose of the second event running every x seconds? This is what is causing all the instances of your tent objects to be set on the same spot.


Oh no! not that. The every x seconds is showing to the player where is going to place the tent.
B
14
S
6
Posts: 63
Reputation: 1,236

Post » Mon Mar 07, 2016 6:32 pm

On the every x seconds event, add this condition for each object: System - Pick Nth Instance. Object is your Tent Roof/Floor, and instance is Self.Count-1.

It might actually just be Self.Count or just -1, Sorry I don't have C2 available at the moment to test, but basically you want it to pick only the last created instance to move for that event. If it doesn't work try the others.
Mistakes were made.
B
54
S
28
G
115
Posts: 1,705
Reputation: 65,083

Post » Mon Mar 07, 2016 10:19 pm

I've run into a similar problem and might have a fix just for you.
If I'm understanding correctly, you're spawning new instances and want to grab only the one spawned?

Create a global variable (or with an array, store the "int(Object.UID)" to that, a suggestion if you've learned arrays yet), and right after the new object is created, set the global variable to:
int(<ObjectName>.UID)
i.e:
int(Tent.UID)
If you do this right after a new instance is spawned (such as when you tell C2 to spawn one), it will pick the UID of the newly spawned object.

In your other events, set an extra condition along the others to pick the UID of the newly spawned object (the one being selected with the mouse? I'm trying to understand your event logic so mind my attempt to help somewhat here), except with that, set the picked UID's value to the global variable name.

Here's a visual example of what I mean:
Image
Zelda Gamekit (my project)



Example capxs:

Zelda-Style Inventory

Zelda Health

3-saveslot system

[url=https://www.dropbox.com/s/d4396pwak0oh7q6/ZeldaDialogueSystem.capx?dl=0]Zelda-like Dialogue[
B
52
S
24
G
30
Posts: 537
Reputation: 19,651

Post » Tue Mar 08, 2016 12:24 am

LaDestitute wrote:I've run into a similar problem and might have a fix just for you.
If I'm understanding correctly, you're spawning new instances and want to grab only the one spawned?

Create a global variable (or with an array, store the "int(Object.UID)" to that, a suggestion if you've learned arrays yet), and right after the new object is created, set the global variable to:
int(<ObjectName>.UID)
i.e:
int(Tent.UID)
If you do this right after a new instance is spawned (such as when you tell C2 to spawn one), it will pick the UID of the newly spawned object.

In your other events, set an extra condition along the others to pick the UID of the newly spawned object (the one being selected with the mouse? I'm trying to understand your event logic so mind my attempt to help somewhat here), except with that, set the picked UID's value to the global variable name.

Here's a visual example of what I mean:
Image


Thanks youu! I didnt tried it yet but i am sure that will works!
Thanks, tomorrow i am going to do this!!
B
14
S
6
Posts: 63
Reputation: 1,236

Post » Tue Mar 08, 2016 12:30 am

what do you mean with "pot"
B
14
S
6
Posts: 63
Reputation: 1,236

Post » Tue Mar 08, 2016 12:33 am

I couldn't wait to try it and.... tatatatatatata ITSS WOOOORKKSS THANKS YOUUU !!!!!!!
B
14
S
6
Posts: 63
Reputation: 1,236

Post » Tue Mar 08, 2016 1:27 am

You're welcome, I'm really glad to help and happy to see you find a solution! Oh, and where it says "Pick instance with UID pot", "pot" is just the global variable's name.
I.e, if it were to say "Pick instance with UID tent", "tent" is the name of your global variable you're using.
Zelda Gamekit (my project)



Example capxs:

Zelda-Style Inventory

Zelda Health

3-saveslot system

[url=https://www.dropbox.com/s/d4396pwak0oh7q6/ZeldaDialogueSystem.capx?dl=0]Zelda-like Dialogue[
B
52
S
24
G
30
Posts: 537
Reputation: 19,651

Post » Tue Mar 08, 2016 10:53 am

Message: ElChuchis can only post plain text URLS until they have 500 rep. 1 URLS modified. Why?
LaDestitute wrote:You're welcome, I'm really glad to help and happy to see you find a solution! Oh, and where it says "Pick instance with UID pot", "pot" is just the global variable's name.
I.e, if it were to say "Pick instance with UID tent", "tent" is the name of your global variable you're using.


Result:

https://gyazo.com/622b2073553839a88abc279cd95bd21d

yeaah! I understood that pot early! THANKSS!!
B
14
S
6
Posts: 63
Reputation: 1,236


Return to How do I....?

Who is online

Users browsing this forum: No registered users and 25 guests