how do i insert a value as part of an objects name

Get help using Construct 2

Post » Sat Jun 17, 2017 9:04 pm

I'm currently creating a game that its movements is based on object location, and so i have set up an area with several objects all labeled with name# example: ground23, i want to make an equation that sets the players position to object by its number such as going up means moving from ground23 to ground13. i have the current object number set as a instance variable within the player such as when on ground23 the value is 23, and when u go up the value goes to 13. the problem is the equation i have set up looks like this "on action, set player coordinates to X: ground(instance value).X Y: ground(instance value).Y but it wont accept it it as a acceptably equation. Does anyone know how how i can write out this equation so it would except it?
B
2
Posts: 4
Reputation: 158

Post » Sat Jun 17, 2017 9:40 pm

Hi,

I did not fully understand. You want something to happen to the player when he is on a specific location? That's no problem. You can simply use the "is overlapping" such as:

PLAYER "is overlapping" GROUND23
ACTION = whatever you want

If I did not understand you - sorry.
Thank you to Construct 2 for giving me the ability to create games without programming knowledge.

My games & gaming portal = DolyGames

If anyone wants to cooperate to help each other Win-Win please email me - I am always happy to discover new opportunities.

Cheers,

COSMOS
B
20
S
9
G
1
Posts: 75
Reputation: 2,152

Post » Sat Jun 17, 2017 9:47 pm

thats not it
i want the player to be on the objects with the same value as the instance variable in its name
B
2
Posts: 4
Reputation: 158

Post » Sat Jun 17, 2017 9:49 pm

though your method would work i would have to set it up for each object in each direction individually
and that would be to much for 50 so objects each level
B
2
Posts: 4
Reputation: 158

Post » Sat Jun 17, 2017 10:04 pm

i found a solution that will work for my game but if some else might use this i would love to still see a solution to this.
B
2
Posts: 4
Reputation: 158

Post » Sun Jun 18, 2017 12:36 am

You said that you use an "instance variable in its (player's) name"

Why not change this (not use at all) and use only one GLOBAL variable to do this job?
It can be called PLAYER_POSITION and every time he moves somewhere like GROUND23 you can SET this PLAYER_POSITION to 23.

Using this 1 GLOBAL variable you always know where your player is and therefore can direct him anywhere you wish such as if PLAYER_POSITION = 23 then put player into position 13.
Thank you to Construct 2 for giving me the ability to create games without programming knowledge.

My games & gaming portal = DolyGames

If anyone wants to cooperate to help each other Win-Win please email me - I am always happy to discover new opportunities.

Cheers,

COSMOS
B
20
S
9
G
1
Posts: 75
Reputation: 2,152


Return to How do I....?

Who is online

Users browsing this forum: richardfu and 33 guests