Fill Array with Sprites

Get help using Construct 2

Post » Fri Jun 10, 2016 9:15 am

@ROJOhound thanks for your reply. Ive tried it with the pick by comparsion event and settet to each footstep a persist behaviour. Works well - thanks for this! If we currently talking about this case ive got another question (of course :D).

So now i got all my footsteps with their special footstep.IID - thats cool but now i want to fire events on special footstep1.IID´s position. Lets say Ive reached the footstep 5 and i want to start an event on its X and Y location. Something like a speech bubble which pop´s up right next to this position.

My Function is: System -> nextFootstep = 5 -> Create object "Speech Bubble" on layer X at (footstep1.IID.X, footstep1.IID.Y)

Now i cant use footstep1.IID.X to specify on which coordinate iam on the stage. It would be great if i could use something like get footstep1.IID(5).X or footstep1.IID(5).Y and create the object with an offset nearby. Basically the Coordinates of the current footsteps are needed.

Should i use an array to store the coordinates of each footstep - or would there be a smarter solution whitout using an array? (Like we did)

I hope you can understand my description. :)

Thanks to you!
B
9
S
2
Posts: 147
Reputation: 1,041

Post » Fri Jun 10, 2016 3:03 pm

@All Just another question: Ive got objects which i disabled on one layout (ingame). Now iam trying to enable them again from my menu layout (reset button) but this does not effect. Is there a special thing i have to pay attention for? Like communication between layers or something for objects?.

on the reset functioin iam using: For each footstep1/2/3/4 order by 0 ascending -> Set collisions enabled. (Ive tried some other events to lick pick all or only a for loop etc.)

Thank you!
B
9
S
2
Posts: 147
Reputation: 1,041

Post » Fri Jun 10, 2016 5:59 pm

The general way to use values from a particular instance is to pick it with a condition the footsteps1.x will be the X of the one that's picked.

You could also not use picking and use footsteps1(5).x to get the X of the fifth instance. But picking is probably easier to read.

You can use an array of you like, I mean if it's easier to understand. It probably isn't needed though since the object list can be thought of as an array too. Reading the manual sections on how events work could be a useful reference.

Generally you need global variables or global objects to pass information between layouts. The persist behavior saves an objects state so it's the same if you leave a layout and come back. If the events are overwriting the state then you'd need to rework the logic of the event sheet.

The overall logic of your game should be pretty much the same as if you made it in any other language. My solutions are probably too terse to be useful since the logic is obscured away so it's not obvious to others.
B
92
S
32
G
110
Posts: 5,295
Reputation: 71,501

Post » Mon Jun 13, 2016 4:03 pm

@Rojohound - thanks again :) Ive found a solution without using an array - it was a bit tricky but at the end it works. Ive got another question (surprise surprise ;) ). Iam trying to set up an inventory book. It should be quite simple. In this case i will definatly use an array but thats not the question right now :).

Ive a book as background, and on this ive placed some symbols (sprites). Now to the question: Is there a simple way to make something like a hierachy? I mean if i blend out the book, the symbols have to blend out too. Or do i have to make an event for each symbol on this book too?

In unity for example - it works if i blend in/out the parent object, it effects the child objects too. So thats basically it. Maybe there is a possability i havent found yet.

Tomorrow i will create an array to set each symbol active or inactive - it depends on if this symbol was found or not. but if i open or shut the inventory book, the symobls have to appear/disappear too.

Thank you very much!
B
9
S
2
Posts: 147
Reputation: 1,041

Post » Tue Jun 21, 2016 3:56 pm

@99instances2go
@R0J0hound


Hey guys!

Ive got another big problem...i run into - and i hope you can help me out with this. At first i should descripe my layout to make it more clear.

Ive got a level_1 layout. This layout has a size with 11800x6600 px. The window size is 1180x660px. The layout got 10 differend layers, filled with sprites. All of them, except the first layer (this is my gui layer) got a parallax with 100,100 to keep scrolling possible.

Basically this level is splitted into two possible perspectives. The first is the map mode. The other is the search mode.

Right at the beginning "On start of layout" iam scaling all this dynamic layers to 0.1 to get the complete stage visible (this is the map mode). My goal: If the player is touching to a specific position, the camera (or better the dynamic layers) should scroll to this position and zooming in at the same time. Ive written two differend events. One for touch input in map mode and one for touch input for the search mode. If iam in map mode, the search mode input is deactivated and vice versa.

So now to my question:

Iam using Touch.X / Touch.Y inputs for both modes (Touch.AbsoluteX/Touch.AbsoluteY doesnt work, because i would need the world space, not the screen space (i think)). To zoom onto a specific position doesnt work. At the moment i can zoom in and out (from 0.1 to a scale factor of 1 and vice versa). this works great. But i dont get it to find a solution how to scroll onto the right position when iam switching from the map mode into the search mode.

Does someone got an idea how to handle this? Or maybe an excample for this kind of problem? Iam absolutly clueless right now, because ive tried so many differend things (scroll to behaviour and and and). But if iam using this option, my target camera objects got an weird parallax/offset.....and......lets forget about this... i think i need the right formula for handling positions, if i got a scalefactor on my layers or something like that.


Every solution would be great. Sorry for the long post. If you need more informations, please tell me.

Summary of my problem: (to make it more understandable :) )

large stage (11800 x 6600), window size (1180 x 6600)
scrolling and zooming in/out depends on mode.
If mapmode to searchmode: Zoom in from scalefactor 0.1 to 1 (for all dynamic layers)
If searchmode to mapmode: Zoom out from scalefactor 1 to 0.1 (for all dynamic layers)

if you are in mapmode and youre taping for example to the coordinate 7545x, 3456y - the window should zoom and scroll to this position. (smooth camera movement that would be important)
if you are in the searchmode (high zoom level) there should be only small position transitions (all touches you do right in the window canvas (tap and scroll to position nearby, tap and scroll to position nearby and so on)). The small camera movements should be also smooth.

Thats basically it.....this thing is driving me crazy, i hope you can help me out!




Thank you very much for your awesome support in this community!
B
9
S
2
Posts: 147
Reputation: 1,041

Post » Tue Jun 21, 2016 5:08 pm

Expressions :

X("layer")
Y("layer")
XAt(index, "layer")
YAt(index, "layer")
XForID(id, "layer")
YForID(id, "layer")
Return the current position of a touch in layout co-ordinates, with scrolling, scaling and rotation taken in to account for the given layer. The layer can be identified either by a string of its name or its zero-based index (e.g. Touch.X(0)). The At expressions can return the position of any touch on a layer given its zero-based index, and the ForID expressions return the position of a touch with a specific ID.

BStateham wrote:Richard, instead of using Touch.AbsoluteX and Touch.AbsoluteY, have you tried using Touch.X("HUD") and Touch.Y("HUD")? These give you X and Y co-ords that are adjusted for the scale, parallax, etc. of the specified layer ("HUD" in this case?

Here is a capx that works (I think)
https://dl.dropbox.com/u/17174841/Const ... nnett.capx
Docs on the touch object including the Touch.X("Layer") and Touch.Y("Layer") functions can be found here.
B
33
S
18
G
28
Posts: 2,493
Reputation: 20,950

Post » Tue Jun 21, 2016 6:51 pm

@99Instances2Go OMG! I didnt knowed i could do that! This my incredible friend - solved my problem! THANK YOU SO MUCH!

I can now check the Background Layer, and because of my fix stage size (11800x6600) iam able to get the real world co-ordinates based on this size (not the scale world co-ordinates like before and wich didnt where matching for the two game modes). Now my zoom works and it gets on the damn right position! AWESOME AWESOME AWESOME!

Thats the thing i was talking about at my very first post (or one of the following): Lerning from the best! @99Instances2Go
B
9
S
2
Posts: 147
Reputation: 1,041

Post » Tue Jun 21, 2016 8:17 pm

Okay of course iam now on the next step. And again - its a little bit weird.

Description:

After my zoom in i set the clicked world space coordinate to Touch_X_Old and Touch_Y_Old, to save the touch position i zoomed in (this works fine). The camera zoomes in and now iam on the search view.

Now to my search Input problem:

On any touch end -> i set Touch_X and Touch_Y to the current position. (The position is inside my window screen, so lets say on the map view i was touching the point 3500x 3500y and iam on this place right now and iam touching nearby, for excample to 4000x 4000x). The camera should move smooth to this location - but it makes weird things.

My setup:

Touch_X_Old/Touch_Y_Old are the position co-ordinates i get from my map view (witch zoomed into search view right now)

Touch_X and Touch_Y will be set if i fire the touch end event. So far so good - i got two positions - the Touch_X/Y and the Touch_X/Y_Old positions. Now i sould be able to set up a simple lerp function right?

Here it is: On every tick -> System -> distance(Touch_X_Old, Touch_Y_Old, Touch_X, Touch_Y) > 20 ->->-> Scroll to (lerp(Touch_X_Old, Touch_X, 0.5), lerp(Touch_Y_Old, Touch_Y, 0.5). If i remove the distance check it doesnt move ... so i think my lerp function is the problem....

Then: On every tick -> System -> distance(Touch_X_Old, Touch_Y_Old, Touch_X, Touch_Y) < 20 -> Set Touch_X_Old to Touch_X and Set Touch_Y_Old to Touch_Y (If the distance is smaller than 20 i have to set the current Touch_X/Y to Touch_X/Y_Old for the next scroll right?)

And basically thats it...but this doesnt work. What is wrong with this events? Ive removed the distance check to see if the lerp function works - but this isnt the case...and i dont know why.


Be a wizard again 99Instances2Go :) (or others)

Much of thanks! :)
B
9
S
2
Posts: 147
Reputation: 1,041

Post » Tue Jun 21, 2016 9:13 pm

I have a lot of things to tell you.

Starting with Delta-time. Speed = distance/time. If you move something pixel by pixel/tick, it will move faster on fast machines. That is because on fast machines the time a tick takes is shorter. As a result there are more ticks in a second. And so, it moves 'the thing' more pixels in a second. If you dont care for that. No problem. But it is just courtesy towards to player to account for that. In the expressions you will find the expressin 'dt'. Want to know what it stand for, search for Delta-time. But the use is simple, in a lerp that would be ...

lerp(A,B,step*dt)

All behaviors are Delta-time corrected by default.

About A & B. A is in fact the start value. B is the end value. And both should be static. If not, the lerp will not reach the end. Because, see. It devides A to B with steps. The result of that is the distance it moves. But if A is getting closer to B in the mean while, you just devide a shortening distance by the same steps. So it moves less and less and less, not ever reaching the end. You will see this, when the lerp is almost done, there gonna be a lot of 'wringle' happen in the pixels. You can solve this by checking the distance from A to B while you lerp. If the distance is less than 4 pixels, dont lerp. But that is not the best solution. Later more.

About the touch x/y. The camera looks at a certain point. To move the camera, you move that point. But, the camera is never ever (maybe once in year) looking at the point the player is touching the screen. You just want the camera to move from current position to the end of the touch. But next touch, the player will not start touching on exactly the point where he stopped touching before. The player is not touching the point where the camera is looking at.

Now, the point where the camera is looking at, you will find in the expressions scrollx & scrolly. What you want to do is scroll from that point the the X&Y from the touch on touch end.

We need 4 variables (or an array, you know how easy that is by now) startX, startY, endX & endY.
On touch end you set startY to scrolly and startX to scrolly.
Also on touch end you set endX to touch.X and endY to touch.Y.

Now the lerp is ...

lerp(startX,endX,step*dt)
lerp(startY,endY,step*dt)

As long as there is no touch end happening those are static, not changing.
Is there a new touch end, the point where camera is right on that moment, is updated, the destination (touchX/Y) is updated. And again they are static for a while. No 'cant reach the distination' problems.

Still suprised you understand my English.
B
33
S
18
G
28
Posts: 2,493
Reputation: 20,950

Post » Wed Jun 22, 2016 8:39 am

@99Instances2Go Thank you very much again and again and again for your description :) ive made a screenshot of my event_sheet how it works for me:

(ive to less reputation points to post an url and if i use the image-url function the file does not appear - so there is a snippet of the link you would have to copy paste)

postimg.org/image/iwxr1vbrb/

Thank you!
B
9
S
2
Posts: 147
Reputation: 1,041

PreviousNext

Return to How do I....?

Who is online

Users browsing this forum: 25games, Google [Bot], jatin1726, kiki4construct, Username05 and 31 guests