99Instances2Go's Forum Posts

  • IID depends on wich objects you pick.

    When you pick only the last created object it has at that moment IID=0

    If you pick them all, it has the last IID.

    If you run trough them with for each (ordered) and use the IID expression + descending, it will start with the last one, and it gets IID = 0.

    IID is not an absolute, static position in the list.

    So, nope, you cant push it into the beginning of the 'instance list'.

    Well technical you can destroy all and create that one, and recreate the others.

    Yes, you can push it to the beginning of the picklist, actualy giving it IID=zero.

  • Ty, updated.

  • I got to dissapoint you, thinking in IF/THEN will give you problems.

    Plz read this very carefully.

    https://www.scirra.com/manual/75/how-events-work

    It comes down to this ...

    Actions run IF the condition is TRUE and ONLY on the objects picked by that condition AND on all unreferenced objects when adressed directly in that action. When there is a pick condition for a certain object, but none got picked, the actions have no objects to run on, even if the condition is TRUE.

    As you see (the document explains it better, at least its English) ... if/then is 1/3th of the story. Wish someone would write those two line in good English for me, so i can copy and past it for ever. : )

    About creating from a famely. Creating from a family creates a random member of that family.

    The creation/spawning action creates objects that are directly adressed by that create action, independent of wich objects are picked in the condition. Of course, the condition must be true for the action to run.

    About the 'run under a flag'. Just make 2 sub events. One containing an empty block (or an on every tick condition) and one containing the flag conditions. Actions go where they belong.

    I hope you have fun with construct as much as i do. For me, coding is the game, not that interrested in the games coded.

  • Use, the last one.

    Used against me, i hope it will be the first one.

  • Are you up for a test ? You write an event sheet for 100 sprites. (Will take you like 105 events) I rewrite the code and reduce it to 4 events, using instances and filtering the instances. Up to it ?

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • Hey R0J0hound thats a nice way to do this. Thank you (for myself).

    For topic starter ... his angles are the path angles.

    He is not allowing the paths to rotate the objects.

    Luckely the path angles are still in the expressions. the sprite.angle is always zero.

  • Edit:

    Dude, i have no idea why i wrote all this, i think i reacted on an old post. Deeply sorry, to proud to just all delete it.

    Tired from work i guess.

    I dont recall using visible/invisible in any of the examples i gave you. I do recall using 1 sprite with all items as a frame in an animation, and a empty frame (frame zero) to represent the 'not found yet' condition, for the book. That simplified a lot of things, including the situation where you would decided to use an array.

    I have no idea how you do this now, iffen you talk about setting an object visible/invisible.

    The sprite.IID is an index. An index means a position in a list. All lists in construct are zero based. Wich list ? In case of the IID it is the position of a sprite in the picklist. If you made footsteps in the layout, and you made them in order, then, when you pick them all, the IDD returns that order. So IID zero is the first one you made in the layout, IDD 1 is the second one you made ... and so on. Hence, you have to create them in the right order.

    Again stressing this 'picklist'. Would you pick the steps that are 'visible', then you make a total other picklist. With other (probaly less) objects in that list. So, those picked objects have another IDD.

    The same objects are in another position (in the picklist) when you 'pick all' compared to 'pick visible'. See it this way. There are 10 appels on the table. When you take them all, you 10 apples picked. If you make a list of those 10 apples, then this list contains 10 apples and each apple is in a postion in the list = IDD. Now if you take only the last 5 apples. You have 5 apples picked, and the apple that was in the list on position 4 when all apples picked is now on position zero.

    In short: IDD depends on wich objects are picked.

    For your collectables, if they are in the new layout made in a differend order, then they have differend IID's in both layouts, when you pick them all. That is probaly your first problem.

    The easy way to go with this is like .... Make a start layout with all the global objects in, on dedicated layers. Global objects !. And just go to the first game layout. The global objects will go with you. For the collectables, this the solution. All collectables must be in that 'start layout'.

    But that means also that you have place each object in an event. Better is to drop the IID construction. And give each instance a instance variable with a unique number. And use that to identify it.

    The book and its sprites must be global. If you use no array, the book does not need to updated when changing layout. Its just fine.

    When using a global array + global objects, the book does not need to be updated when changing layout. (not to my knowledge)

    About the array. Getting things out of it.

    First you must understand that an array is a list. Lists go with indexes. A value sits on a certain index. The index is in the form of city,street,housenumber (x,y,z). The value can be number (3 dogs living there). Or a string ("Lukaku" living there)

    Forget the z. You wil kinda never need to use it. So from now on i speak about x,y.

    Now, the X axis is any position in the array (number,zero)

    (7,0) lays on the X-axis. So does (12,0) and (9999,0).

    As you see, the X-as is using the zero index on the Y-axis. Or, an array containing only values on the X-as (1Dimensional) must have a size of (amount of x,1,1).

    This is what you have, and there is no room for additional values on the Y-position. I do not talk about the Y-axis, because using the term Y-axis has only sense in a 3D array, when (ofcourse) the Y position is using the zero position of the Z-position.

    So we talk about the X-axis and about Y-postions. X-axis any position in the array where the Y-positon is zero (x,0).

    X-axis and Y position.

    So if you want to store values on Y-positions, the size of the array must be (amount of x, amount of y + 1). Else there is no (5,1) or (5,7) or (5,9999) available. (5,0) = de X-axis.

    Why is this importand ? Because we usaly want to loop on the X-axis. We usaly want to push and pull on the X-axis.

    Okay, back to index and value. To start with the expressions. There are expressions for values. And there are expressions for the index.

    For the in index ....

    CurX

    CurY

    CurZ

    The current zero-based index for each dimension in a For each element loop.

    For the value ....

    At(X)

    At(X, Y)

    At(X, Y, Z)

    Retrieve a value at a position in the array. Indices are zero-based. Reading values outside the array returns the number 0. If the Y or Z indices are not provided then 0 is used.

    CurX has only a meaning when using a array > 'For each element' loop condition. CurY and curZ i only use when dealing wit a 3D array.

    So, when you use the loop 'For each element X', this loop is running over each POSITION on the x-axis.

    The expression CurX returns the position where the loop is at that moment.

    So the value is at Array.At(CurX,Y-position)

    But you can use any loop. If you have instances with a instance variable containing a number (dont forget first number should be zero, not 1) then you can ....

    For Each Ordered (by that instance variable)

    The value is now at Array.At(sprite.instancevariable,Y-positon)

    You can use a regular For loop.

    From "i" 0 to sprite.count - 1

    value = Array.At(loopindex("i"),Y-positon)

    pick nth instance .. n = (loopindex("i"))

    action ... set sprite.somevariable to value

    But you dont need a loop to retreive one item from the array.

    The value is just at Array.At(X-position,Y-postion)

    Storing in the array is just the same. Same conditions, only now we need ACTIONS.

    You can use a regular For loop.

    From "i" 0 to sprite.count - 1

    Set at XY ... x =loopindex("i") ... y =Y-positon ... value = the value you want to store

    Or a For Each Ordered (by that instance variable)

    Set at XY ... x =sprite.instancevariable ... y =Y-positon ... value = value you want to store

    Or just, with no loop

    Set at XY ... x = X-position ... y =Y-positon ... value = value you want to store

    Hope this clears some things out so you can manage what you want to. I have no idea what you are actual dooing. But i see that the size of your array is to small. And i see that you try to set the 'numbers' or the 'IDD' on the Y-Axis, and that will make it to complicated, also for me.

    If you want a numberd list, trow them in the X-axis (x,zero).

    Any other value goes on the Y-position. (x,y-position)

  • Make a family more containing objects1 & objects2 ... lets say .. FamilieAll

    Layer Objects1 is visible

    or

    Layer Objects2 is visible

    sub ... Cursor is over FamilieAll

    Set cursor to Hand

    else

    Set cursor to Normal.

  • Afraid that is not gonna work.

    Cursor is over Menu(family)

    Set cursor to Hand

    else

    Set cursor to Normal.

    If this is the only cursor change happening.

  • https://www.dropbox.com/s/dwx5nslrekv97 ... .capx?dl=0

    Your random paths are (i think) to fast calling for a new path.

    On failed is not not needed.

    Those Pathfinding_Helper's are a great idea !

    There are only 4 animations for 360 possible directions.

  • Well, when static it does not get a reset when running its top-event. So, yes, then it acts as a global, for that 1 layout. Its not a global as in the sense of 'Global'.

  • 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.

  • That is only one half of the story your capx tells.

    Yes, you can pick based on a lot of things. In the end, this is not what really matters.

    Because, see, you pick now those objects that you want to give the state 'state'. You still have to pick the others go give them the state 'unstate'. I dont know what you plan to do, set them solid/not solid ... colission/not ... lets just call it 'state'.

    You gonna make Two internal loops, one for the 'state' and one for the 'unstate', if you do it this way. Not really optimized. You dont have the 'unstate' coverd in that capx, why i say its half the story.

    Try to do it in 1 loop. 2 Examples in here.

    https://www.dropbox.com/s/jhiouuxy5jemq ... .capx?dl=0

  • 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.

    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.