WarpedOldMan's Forum Posts

  • Ah hehe, that does... some of what I need. But I'm not sure I can adapt it for my all of my needs. Importantly, I need to mirror the values of keys between two instances of the same object. And, the keys can't be numbered unfortunately (sneaky you). Well, they could but it would get confusing as I would have to place the key name in the value of the key or an index; then use tokens and such to get a "key" name, index, or value depending on where I put each.

    However, excluding one key from this mirroring process is my problem, not the basic mirroring of the values.

    In order to differentiate between the two instances of the object, I need to keep one key's value separate. This is the "alias" key. In my post I mention that the "alias" key of one instance is set to "temp" and the other is set to "default". This is the only key that I don't want to mirror.

    I thought that the problem might exist with how the "for each key" condition on a dictionary object works. It's not impossible to just roll my own, so to speak, but since dictionary keys aren't indexed by default, I would have to do that myself. Which would get a little messy and I consider that route something of a last resort.

    Heh, I'm never quite sure if I'm going in the right direction, but can anyway see why I'm placing the object in two different families? I've done similar when it comes to managing collisions between instances of the same object and I seemed to have similar needs in this situation.

    Again, if anyone is having trouble understanding my first post's explanation of what I'm trying to do, then I can make an example .capx.

  • I'm having a little trouble with this one.

    So I have a dictionary object. At runtime I create two separate instances of this object. Each instance is given an identical set of keys. One is intended to store some default values so that I can restore the other instances values to an original state periodically.

    However, I also want to skip a key in the process. What I'm currently calling the "alias" key, which stores a little name of the instance to help differentiate between the two instances.

    To make this a little easier (or so I thought), I placed this dictionary object in two families: "dict1" and "dict2".

    Then, on a function, I pick each instance through the two families.

    dict1 - Key "alias" = "temp"

    dict2 - Key "alias" = "default"

    Now, these two instances and only these two should be picked.

    Then, in a sub-event I use a "for each key" condition on the "dict1" family.

    And in another sub-event I invert the following condition.

    dict1 - Current key = "alias"

    Now in the actions I do:

    dict1 - Set key dict1.CurrentKey to value dict2.Get(dict1.CurrentKey)

    I thought that this would loop through each key and match the value unless the current-key matched the key that I didn't want to restore. In this case the "alias" key.

    However, currently it's not skipping that key.

    Any help would be greatly appreciated. I may just be misunderstanding something simple. If necessary I can provide an example .capx

  • I used your method in my project. It seems... to work. I see now why my method wouldn't have produced quite the desired results. Oddly, I'm still not sure why I was getting the result that I was, i.e. the jumble of blocks.

  • I'm going to bump this thread; I'm hoping that perhaps someone might see my problem.

    I'll also take the opportunity to correct a small error I was making (though sadly it doesn't solve my main problem).

    In the sixth action of the first event, I'm offsetting the Y position of the sprite extra, based on it's "arrayZ" value. However, I'm offsetting the sprites with a higher "arrayZ" value in the wrong direction. Sprites with an "arrayZ" value of 1 should appear to be higher than those with a value of 0.

    So instead of

    self.arrayY*(self.Height*0.50)+(self.arrayZ*(self.Height*0.5))+128[/code:2jywncrp]
    
    It should be 
    
    [code:2jywncrp]self.arrayY*(self.Height*0.50)-(self.arrayZ*(self.Height*0.5))+128[/code:2jywncrp]
    
    Also, for those (I hope) looking at my first post, I'll try to state somewhat more simply what I'm trying to do.
    
    In my example, I use an array to assign a unique X, Y, and Z to 50 sprites. I then use these values to give each sprite a coordinate (an X and Y position in the layout) that should simulate the effect of a 5x5x2 stack of blocks. I've checked, and I'm fairly sure that I've been mostly successful. No sprite shares all three values of their "arrayX/Y/Z" variables with another sprite and all positions in the array are filled and correspond to one sprite and only one.
    
    However, since my first post, I have discovered that though they don't share this, some of them do share X and Y coordinates in the layout when they should not, as they also share the same "arrayZ" value.
    
    I don't know why this is, but it's likely connected to why when I try to use a "for each" condition ordered by the sprite's "arrayZ" variable, that I get a jumbled mess instead of an ordered and properly depth-sorted stack.
  • I appreciate the reply, I'll spend some time reading what you have said to see if I can apply it to what I am doing.

    Simply put, the eventual goal was to use a 3D array or arrays to help me generate and keep track of terrain.

    Construct 2 is a 2D engine, but in my little game experiments I usually try to inject some element of depth to the game environment. This is often done with the use of layers and different parallax values; but there are other ways as well. Some have attempted to make use of an Isometric perspective, "top-down", or orthogonal.

    I admit that there is some confusion of the terms, but my understanding is that the orthogonal perspective differs from purely top-down perspective games in that it attempts to simulate an angled camera such as 45 degrees.

    What I'm trying to do here (at least I think) is to use an orthogonal perspective. This can be done without the use of an array object. It differs little from the creation of a normal tile-based top-down or isometric game. But I wanted to add an extra dimension if possible. And one idea that came to mind to simplify the process of assigning an X, Y, and Z dimensions to a sprite and managing those, was to use an array/s.

    When using an Isometric or Orthogonal perspective in a game, one of the basic functions of such an engine is the depth sorting of the various 2D elements, e.g. when a player sprite moves behind or in front of another object, the various sprites involved need to be layered accordingly. Normally, when using an orthogonal perspective, this is simple to do (though a bit more complex to make efficient). In my case, I'm just trying to add another somewhat imaginary dimension.

    I'm very much stumbling through this as that is my normal process with such experiments so it's possibly I've overlooked something very simple related to my problem.

    I'll try to add more information soon to better explain my problem and what I am trying to achieve.

  • So, I have an array with a width of 5, a height of 5, and a depth of 2.

    And, I have a sprite with a width of 70 and a height of 100.

    For testing purposes, the sprite that I am using is intended to be a cube viewed from an orthogonal perspective.

    Next what I do, is best demonstrated if I first start with another image.

    On a triggered event I spawn a sprite using the "for each element" condition of the array.

    The sprite has 3 instance variables, "arrayX", "arrayY", and "arrayZ". I don't know what order the "for each element" conditions uses to loop through the array, but that isn't particularly important. The intention is to essentially have a sprite (only one sprite) linked to each position in the array.

    Each time an object is created, I set it's instance variable e.g. "arrayX" to the current position in each dimension using Array.CurX/Y/Z.

    Once this is done I then use these instance variables to offset the position of the sprite in order to create a grid layout. Importantly though, there is a third dimension, so I offset the Y more depending on the sprite's "arrayZ" value, in this case either 0 or 1 I believe.

    On layout start, I get this

    Which, so far, is good and is exactly what I expected.

    Next, I have a function that I thought would be rather simple. When the function "sortz" is called, a "for each" loop is run, ordered by the sprite's "arrayZ" variable, the sprite is moved to the top of the layer. This should first run through all the sprites with an "arrayZ" value of 0, move them to the top of the layer, then move onto the sprites with an "arrayZ" value of 1 and move them to the top.

    Since no sprite with the same "arrayZ" value should share the same X and Y position on the array, it should create the effect of a stack of blocks.

    What I get is this

    What I expected to get is this

    I'm not really sure where to go from here. I had thought that if I had a sprite corresponding to each position in the array that the rest would be simple. I've been through the manual section regarding arrays and checked the forums for details on using 3D arrays.

    Also, using a "for each" loop, I've counted and there are 25 sprites with an "arrayZ" value of 0 and 25 with a value of 1. So I have the correct number of sprites in each layer.

    Note: I add "128" to each sprite's X and Y so that the group will be moved down and away from the top left corner of the viewport. This allows me to see all the sprites. The results are the same with or without this so I don't believe it is related to my problem.

    If necessary I can clarify further and even upload an example capx, but perhaps the solutions is something simple that I am overlooking.

  • I don't expect a quick reply, or any reply at all given the understandable inactivity of the CC section of the forum, but I'd hoped that someone might be able to help me with a problem.

    Currently, I'm doing this,

    <img src="http://i.imgur.com/5EYyIbs.png" border="0" />

    At the moment, storing this few of names in a hash table isn't inconvenient, but I feel like there should be a better way to do this. Eventually I will be needing to store more object names in the hash table.

    All of these objects are in a family, but I can't figure out a way to do a "For Each Object OID or Object type" in a family in order to condense these actions.

    A solution to this would help me in many other areas of my project as well so any ideas would be greatly appreciated.

    Update: I've solved my problem. "For Each" conditions and families seem to work just fine. I was just being an idiot and forgot to stringify the OIDs that I was storing. I can now store an entire families' objects' OIDs as names in a hashtable.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Though I believe that there are multiple ways to accomplish this, I used this plugin.

    CSS Import Plugin

  • Sorry for the constant replies. I believe that I have solved this one. Although quite what I was doing wrong I am still not sure.

    Though it is unlikely that anyone else would want to do this, as far as I know, using the simple "z-index: -1'" in CSS seems to place the video in the background.

    Naturally you will want to ensure that all other layers above the video have a transparent background if you want to see the video.

  • Bump... again. I was just wondering if anyone knew what I might be doing wrong here? It may be something simple but it's also beyond my poor knowledge of construct 2 and CSS.

  • So I managed to manipulate the video element to an extent using CSS.

    My experience with CSS is quite limited however I can for example, hide the video with a simple: "visibility: hidden;".

    However, if I try to change the z ordering of the video element by applying: "z-index: -1;", The video seems to remain on top.

    I have placed other objects in the layout on multiple separate layers (some above the video object). When using "z-index: -1;", I see none of these other objects on top of the video.

    Would anyone have any thoughts or suggestions as to what I am doing wrong?

  • Ah, thank you. That sounds like an option worth pursuing. I'll try to post back here if I get it to work.

  • Bump.

    Just wanted to confirm that this is the final word on the issue and that as it stands, there exists no practical way to render a video in the background, behind dynamic elements in C2.

  • Thank you for pointing that out. I have looked into this plugin already though, and at it appears at least, by default, to render on top of all other elements in the C2 runtime. I don't know if it is possible to force a different behavior however.

  • Just a quick couple of questions regarding Construct 2.

    Is C2 capable of video playback? And if so, more importantly, can C2 render dynamic elements on top of the video region?

    I should add that a sprite animation is not a viable option in my case.