Mini Map Help

Get help using Construct 2

Post » Mon Jan 27, 2014 1:04 am

Hello Guys,
I would like to appear on my minimap the energies, and the enemies moving like in the game screen. The player_icon work, the other icon not. Anyone can help me to solve this?

https://www.dropbox.com/s/18qh5khe0fydnw7/testMap.capx

Thank you!
B
43
S
7
Posts: 79
Reputation: 4,295

Post » Mon Jan 27, 2014 10:29 am

@dznerpro

Hey,

Your problem is quite clear here : the link between an object and its map representation isn't defined. To put it more clearly, how would the map update an enemy position if each enemy_icon isn't "connected" to an enemy ? I don't see, as a computer, how I would do it as your system is right now.

So the solution now.
1/ you need a map initialization. In the initialization, you'll spawn an enemy icon for each enemy on the game. Same goes for energy, so I'll just explain for the enemy for now. Every icon needs a variable, "targetUID" for example. This variable is set during the initialization to the enemy.UID. The positioning is then done exactly like you did for the player icon.
2/ you need a map icon adding system, to spawn a new icon on the map every time a enemy is spawn.
3/ during the map actualization, position the player icon like you did, then do a forEach on all the enemies, select the corresponding enemy_icon on the map (using the variable we added in 1/), and then position the icon on the map.

I see you have a licence for C2, so I'd suggest you use families for "mappables" objects (i.e. the objects of the game that have a map icon) and a family of "map_icons", as all those icons have exactly the same way of initializing/updating/destroying.

I hope this explanation is enough, I'll put some code in if you need though. Don't hesitate to ask if anything isn't clear.
B
17
S
8
G
4
Posts: 473
Reputation: 6,191

Post » Mon Jan 27, 2014 2:22 pm

Thank you Gumus.
I am newbie in Construct 2 and I dont know how to start solve this minimap how you said. Sorry.
I'll trying do that with families, but i'll back if I dont.
Thank you again.
B
43
S
7
Posts: 79
Reputation: 4,295

Post » Mon Jan 27, 2014 3:26 pm

@dznerpro

If you're a newbie in C2, let me give you this example.

This is a simple minimap, a button to spawn enemies, and the code is commented to explain everything.

If you have any question, feel free to ask.

I didn't put in the families to simplify everything. You can now just duplicate everything for your "energy" object, or for the player too.
B
17
S
8
G
4
Posts: 473
Reputation: 6,191

Post » Mon Jan 27, 2014 5:00 pm

Thank you very very very much, Guizmus.
It will help me...
I never used 'for each'. I will to study it.
Thank you
B
43
S
7
Posts: 79
Reputation: 4,295

Post » Mon Jan 27, 2014 7:09 pm

Guizmus, i do by myself and the minimap worked fine.
But, i have a question. If the map is bigger, the game can get slow, can't?
B
43
S
7
Posts: 79
Reputation: 4,295

Post » Mon Jan 27, 2014 7:44 pm

@dznerpro
Yes and no. The map size isn't the problem. The problem is the number of points on the map and the trigger "on every tick". My code wasn't optimized, I put it like this for explaining. You'll make it faster by updating the map every 0.1 second for example, or 0.2. Also, you could hide the points of the enemies whose icons are outside of the map if you have a big layout. There are numerous ways to optimize this for a bigger map, but it would be a little harder to read/write.

I suggest you don't bother too much about it for now. Optimization should come later in your game, when it starts to be a problem, or when you are shipping it to another support than PC. When this comes, take a look at my signature ^^

B
17
S
8
G
4
Posts: 473
Reputation: 6,191

Post » Mon Jan 27, 2014 11:29 pm

Thank you again
B
43
S
7
Posts: 79
Reputation: 4,295


Return to How do I....?

Who is online

Users browsing this forum: No registered users and 29 guests