I'm blocked

Get help using Construct 2

Post » Fri May 02, 2014 9:51 am

Hi,

I'm lost about pass values from / to another action. I need some help so I'm blocked.

1) I want recover the value from an "touched" object and store globally.
2) From these globally value I want "repeat for each key" and from the values that I found I want perform some action, color change for example over the objects values.

I'm blocked :cry: I read the manuals, search the forum but I don't have idea how handle it.
The 1) is ok. I have a instance variable with the name of the sprite and when I "touch" I set the value to a instance variable of the dictionary. But no more...

How can I do the point 2) ?

Thanks in advance.

Salut,
Josep M
B
18
S
2
G
2
Posts: 64
Reputation: 1,220

Post » Fri May 02, 2014 10:10 am

You are building a game board risk type game right?

Take a bit of time and watch this series on containers 8 parts.

Edit: the videos will explain more, and in more detail than I ever could :)
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,718

Post » Fri May 02, 2014 6:18 pm

Yes. I try it :)
Thanks for answer and point me...
B
18
S
2
G
2
Posts: 64
Reputation: 1,220

Post » Mon May 05, 2014 7:19 am

Hi,

Well, after view the videos I understand the use of containers and how select the zones using others frames.
In my case then I will have a unselected and a selected image of each zone. All the zones are different so I don't know if is better put all the zones inside a container. So each sprite must be assigned with her own triggers, isn't?

Salut,
Josep M
B
18
S
2
G
2
Posts: 64
Reputation: 1,220

Post » Mon May 05, 2014 9:20 am

@JosepM
1 sprite for zones. With instance variable active. Drag that sprite out for each zone. place into container with city name. add touch and watch the magic. Construct2 is super smart. Each zone sprite will take on the characteristics of the origanal. But it is smart can detect which is being touched. I added a text box which shows which sprite is being touched (id) and city which is part of that sprite, and changed image to reflect active.
So container you will drop everything related to city (marker, name, units, whatever) and drag and place them where you want them. You want to re-use objects not clutter your game with 1000's ;)
Example is Pretty basic, but will help you on your way.
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,718

Post » Mon May 12, 2014 1:56 pm

Hi @Dutoit,

Many thanks for your example, finally I was able to put my map working. Attach the .capx so maybe can be usefull to anybody.

Few questions more.

1)Why the city tokens select also the zone? I touch the city and the zone react to the touch. The city pass the event to the bottom elements? Can be blocked?

2)How call a function from other event sheet? If I add a the function into other event sheet the call doesn't work, or I don't have idea how call it.

3)Can be used with an array to stablish the destinations from a select zone?

Zone 1: 2,7,6
Zone 2: 1,3,6,7
Zone 3: 2,4,6,7
Zone 4: 3,5,7,6
Zone 5: 4,7,6
Zone 6: 1,2,3,4,5
Zone 7: 1,2,3,4,5

So when I touch a zone I get the NameID check the array and with repeat for each element assign the frame, but I don't know how assign the sprite to the frame inside the repeat so each sprite is diferent.
Thought?

Salut,
Josep M
You do not have the required permissions to view the files attached to this post.
B
18
S
2
G
2
Posts: 64
Reputation: 1,220

Post » Mon May 12, 2014 2:45 pm

Quick reply, as I don't have much time.

1) put a condition that touching zone isn't touching sprite.
the X is right click and invert which means opposite of what condition is saying.
See image attached -
put condition not touching sprite.JPG

touch X(is not) touching sprite then do this...
2) Make one main event sheet and include all event sheets into it.
multiple event sheets.JPG

3) I think I understand what you are saying, but I'm getting old :roll: and not as sharp as I wish I was.
You can do this, and there are number guys who have more knowledge about this than me.
I usually hardcode everything. Or, use invisible textboxes with data that I can retrieve. Or on startup save data into instance variables.
THen use foreach sprite.... bla bla bla
look system > loops >

Each sprite has unique id, and each sprite can have instance variables that you can save data to that is unique to that sprite.
I used something similiar to tutorial using custom paths using waypoints. Don't have link offhand.
It uses instance variable to store waypoints.
Here is capx from tutorial:
custom_paths_using_waypoints.capx


Hope that helps a bit

Edit: look at this demonstrates sort of what I am saying.
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,718

Post » Wed May 14, 2014 10:32 am

Hi @Dutoit
I explain with more detail what I want to accomplish.

Now I have the “hard coded” version of the map definition, I mean that I defined for each zone the posibles destinations in “touch event”. Thank you for your tips. :)

I want that these posibles destinations will be drive through an array. For each zone I have an array with the posibles destinations, so when the user “touch” one zone, I want repeat for each element of their array and change the frame, so maintain the zones connectors will be more easy.

Pseudocode.

Load from an URL or file the JSON of the arrays for each zone.

Code: Select all
Zone #A touched
if active=true of Zone #A
repeat for each element X of array #A
   Change frame of zone X
   Set active =true
end repeat


On this way I can update the zones destinations from an array and not by “hard code”

It’s posible do that? how can I refer to a sprite inside the repeat loop?
Can I pass sprite reference to a function?
I read about the UIID but don’t know how pass it?


Salut,
Josep M
B
18
S
2
G
2
Posts: 64
Reputation: 1,220

Post » Wed May 14, 2014 10:59 am

JosepM wrote:Hi @Dutoit
I explain with more detail what I want to accomplish.

Now I have the “hard coded” version of the map definition, I mean that I defined for each zone the posibles destinations in “touch event”. Thank you for your tips. :)

I want that these posibles destinations will be drive through an array. For each zone I have an array with the posibles destinations, so when the user “touch” one zone, I want repeat for each element of their array and change the frame, so maintain the zones connectors will be more easy.

Pseudocode.

Load from an URL or file the JSON of the arrays for each zone.

Code: Select all
Zone #A touched
if active=true of Zone #A
repeat for each element X of array #A
   Change frame of zone X
   Set active =true
end repeat


On this way I can update the zones destinations from an array and not by “hard code”

It’s posible do that? how can I refer to a sprite inside the repeat loop?
Can I pass sprite reference to a function?
I read about the UIID but don’t know how pass it?


Salut,
Josep M


Load from json using ajax works perfectly.
sprite.uid / sprite.iid gives you the unique id of the sprite. But I don't like to use this.

My preferred way is to create an instance variable and name each one, that way I can control the assigned number.
And you can retrieve it, condition it, manipulate it etc etc easy enough.

Point is. You can now check against the array.
So if instance variable = to any of the array numbers then sprite frame 2 to highlight possible moves, or whatever.
You need the instance variables to use in conditions, especially when moving pieces, highlighting active/non active etc etc.
UID/IID should never be hardcoded.

So if zones destinations (instance variables) = array possibles destinations then ...[do this, or that]

Don't hold me to this:
But instance var
City Name: London
Zone: 1
Section: 1

City Name: Paris
Zone: 1
Section: 2

Array
Zone1
:: 1
:: 2
Zone2
::1
::2


if zone.zone = 1 (this automatically selects all sections)
if you want specif section, then add another condition if zone.section = 2 (this narrows it down to paris)

So foreach zone...
Condition: zone.zone = 1
change frame bla bla bla
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,718

Post » Wed May 14, 2014 12:11 pm

very very raw example of destination selection.capx
@JosepM,

Very Basic example.
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,718

Next

Return to How do I....?

Who is online

Users browsing this forum: Yahoo [Bot] and 29 guests