Cowdozer's Forum Posts

  • From what I understand, if you use multiple layouts, you will have no way of overlaying the menus (if that is desired) or having a transition effect from one to the other in which they're temporarily both visible at the same time. Also, I think you could make a simple function that makes one layer visible and hides the others. Actually, why don't we just try that...

    dl.dropbox.com/u/117529592/Construct%202/Forum%20questions/LayerSwitchFunction.capx

  • If the plugins you find don't quite do what you want them to do, you should be able to make it work using the event system. I read about Functions in Construct 2 today and that they could be used recursively (which means that the Function can call itself) and thought that your particular problem would be a good exercise to work with it.

    Here is a capx that matches adjacent tiles of the same colour. Any tile to the left, right, top, or bottom is considered adjacent. I think this is the behaviour you're looking for, although this is not necessarily the best way to implement it. I was just having some fun, and wanted to show you that what you want to do is possible.

    dl.dropbox.com/u/117529592/Construct%202/Forum%20questions/MatcherPuzzleDemo.capx

    Left click to match, Right click to change colours. Enjoy!

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Thanks Yann! It's still a little confusing, but your explanation really helps! That's a very good point about black being the colour of nothing in the editor. But if that is indeed the case, then why is the editor's colour of nothing typically light blue? If you make all layers invisible or make them (semi)transparent, you see that the background colour of the editor is light blue, not black. Do you think that maybe the Destination In effect is burning through the editor's background colour as well? If so, I'd consider that a small bug in the editor view.

    Another potential editor view bug is that I found you could set the light blend mode to XOR and get the same effect as Destination Out, but the editor view would show it opaque (as if blend mode were Normal). There seem to be some other weird things with XOR, such as it still having an effect on the overall image even if you make the layer Transparent. Either I am misunderstanding something (quite likely), or it's behaving incorrectly.

    I'll try to paraphrase and expand on your overall explanation:

    My understanding is that rendering is done starting with the lowest layer, and each layer renders objects using z-order from lowest to highest. Force Own Texture will render a layer on its own, independent of layers above and below it, and the visual effect of this is that blending modes on objects within that layer will only be applied to objects and the background of that layer, and not to anything rendered on lower layers. Once it's rendered to a texture, the layer will be rendered over the output of the layers below using the layer blend mode. This all seems to make sense and agree with my observations, EXCEPT:

    I found another way to do this lighting without Force Own Texture! This time, I have the lighting sprites blend mode Destination Out (same as demo), and the Lighting layer is Black, but instead of enabling Force Own Texture, I set Opacity to 99.999%. It seems that layer opacity has an effect as to whether a sprite's blend mode stops at the current layer or applies to all layers below it. If the layer is opaque, sprite blend modes apply to everything below it, but if the layer is semitransparent, sprite blend modes only apply to the current layer. Since Opacity is at 99.999%, it's enough to trigger this different behaviour, but 99.999% is visually opaque (it might indeed be opaque, although I'd have to screenshot and test pixel values).

    I wonder, is this method notably more efficient? From what I understand, it should be considerably more efficient. I also wonder if XOR is more or less efficient than Destination Out, because those two blend modes seem to be visually equivalent in this situation.

    I've updated the capx and html with a third layout. The third has settings:

    Lighting layer: background black and 99.999% opaque, blend Normal.

    Lighting sprites: XOR for mouse, Destination out for 8Direction.

    capx

    dl.dropbox.com/u/117529592/Construct%202/Forum%20questions/LightingAndBlendModes.capx

    html demo

    dl.dropbox.com/u/117529592/Construct%202/Forum%20questions/LightingAndBlendModes/index.html

    Aside (not really important):

    One thing that I could see value in is having a Force Own Texture mode that forces this layer and all above layers to a texture. I think this would allow for implementation of certain effects more easily (or maybe just conceptually more straightforward), but make other effects impossible. I think it's probably fine as it is, and you can probably get whatever effect you want with enough layers and the right settings.

    Thanks again for your help!

  • *bump* Is there anything I can do to make my question more clear, or is everyone else just as confused? :p

  • I think this is how Ashley was suggesting you select the items using the Pinned object's PinnedUID.

    System.For each [Family]

    System.Compare two values: [Family].Pin.PinnedUID = Heroes.UID

    Your way does work, but hopefully you can get this working, as it is a nicer solution not requiring extra variables.

  • Hi, I ran into a scenario where I had multiple characters on screen with effect items pinned to them. Whenever a character dies, I need to destroy the effects associated with that character. My first solution was to add instance variables to all characters. When creating each effect, I would do something like:

    Effect1: Pin Pin to Character (position and angle)

    Character: Set Effect1UID to Effect1.UID

    And then when a character dies, choose effect instance by:

    Effect1: Pick instance with UID Character.Effect1UID

    It would be nicer if I didn't need to set and refer to the instance variable like that. It would be nicer if, on death, I could simply say:

    Effect1: Pinned to UID Character.UID

    I've included code to add that functionality to make it super easy for you if you think it's a good idea!

    edittime.js:44

    AddNumberParam("UID", "The UID of the object this object is pinned to.");
    AddCondition(1, cf_none, "Is pinned to UID", "", "{my}ned to UID <b>{0}</b>", "True if object is pinned to the object with given UID", "IsPinnedTo");

    runtime.js:139

    Cnds.prototype.IsPinnedTo = function (uid)
    {
         return !!this.pinObject && this.pinObject.uid === uid;
    };

    Also, if you do agree that this change is useful, it's probably worth removing the text "Pin " on this line since "Pin" is implicit in "{my}".

    edittime.js:65

    //results in "Pin Pin to obj (method)"
    AddAction(0, af_none, "Pin to object", "", "{my} Pin to {0} ({1})", "Pin the object to another object.", "Pin");
    //results in "Pin to obj (method)"
    AddAction(0, af_none, "Pin to object", "", "{my} to {0} ({1})", "Pin the object to another object.", "Pin");
    
  • GeometriX's example of how to select a clicked instance is good. If you can't open it, though, take this capx. It appears that GeometriX is using the latest beta version, so I just reverted it back to the release version of Construct 2, which you probably have.

    dl.dropbox.com/u/117529592/Construct%202/Forum%20questions/temp/bluegreen.capx

  • On Wikipedia's definition of "Programming Language":

    programming language is a notation for writing programs, which are specifications of a computation or algorithm. Some, but not all, authors restrict the term "programming language" to those languages that can express all possible algorithms.

    So yes, it is debatable as to whether RegEx is a language since it's not Turing complete (but neither is plain SQL). I agree that RegEx and SQL are not at all in the same category as the others we've listed, but I personally don't mind if someone calls them programming languages or something else. I did not intend to be misleading by using that term.

    Thanks, I see from your links that Oracle's databases have functions and in IBM DB2 you can add user-defined functions. Definitely worth using if you have a need for it and aren't worried about making your SQL queries slightly platform-dependent.

    I watched your Plugin tutorial and it was a nice intro. :) Construct 2 seems very easy to extend that way!

  • Yep and yep. It's certainly not a Turing complete language (you can't make it do everything), but it's a great example of a domain-specific language. For Regular Expressions, its domain is pattern matching and replacing text. I'm not sure if SQL has RegEx support... I know there is a LIKE clause, which uses a simple (but non-RegEx) syntax. But Javascript definitely has RegEx, and it makes parsing strings very easy compared to using nested for loops, if statements, and variables pointing to different indices. It's not going to blow your mind in the same way that Lisp might blow a Java programmer's mind, but it is a prime example of why learning more languages gives you more effective tools as a programmer.

    BTW, I see that you've done a plugin tutorial video! That's greatly appreciated, and I'm going to have to check it out soon. :)

  • Hello! This is my first week with Construct 2 and I'm excited with what I've seen so far and amazed by the length of the FAQ!

    My question is regarding the compositing process in general, as I'd like to have a better understanding of how layers, z-order, and blend modes affect the final image.

    A specific scenario I have been unable to understand is in regards to "spotlight" effects:

    In the Lighting Demo, this is achieved by having a lighting layer with a black, opaque background. The "spotlight" sprites on top are blended as "Destination out" in order to "burn a hole" through the black background. Then, the layer is rendered through "Force own texture" (it's necessary but I don't know why) and blended as Normal onto the layers below.

    My initial attempt to do the same effect was like this:

    Lighting sprites are blended as Normal onto the lighting layer. The layer is otherwise transparent, and the layer is blended as "Destination in" onto the lower layers, to hide any area that is still transparent on the lighting layer.

    This appears to work perfectly in the editor, but when running the game, the area that should be black is actually transparent, and I don't know why or how to fill it in. Choosing "Force own texture" on the layer has no effect. To show the difference, I included both techniques in a project, and coloured the html demo's background purple so the transparency problem in my technique would be obvious.

    capx

    dl.dropbox.com/u/117529592/Construct%202/Forum%20questions/LightingAndBlendModes.capx

    html demo

    dl.dropbox.com/u/117529592/Construct%202/Forum%20questions/LightingAndBlendModes/index.html

    (Sorry for not having clickable links, but I'm a new user and the forum disallows it)

    If anyone could explain why I end up with a transparent background (and if I can make it black), why it looks right in the editor, how "Force own texture" affects the rendering process (I know it renders the full layer separately, but what are the implications aside from performance), or how layering and blending work in general, it would be greatly appreciated!

    Thanks!

  • Hi Velojet,

    I wouldn't normally bother bringing up a post that is over a year old, but it has been listed in the General FAQ and I wouldn't want people new to the platform to be misinformed about the design of Construct 2's event system.

    As you're aware, Construct 2's events allow users to "Pick" one or more objects implicitly, rather than assign specific objects to variable names, as you would in a language like Javascript. This is no more a kludge than how the "this" keyword in Javascript is implicitly assigned within a function to a particular object based on how the function was called. They are meant as conveniences. There's a very popular language used to sort, filter, and modify tables of data, called SQL, which behaves very similarly: you ask it to select rows based on the contents of the rows, and then you tell it what to do with each of those rows. SQL does this job wonderfully, and to do the same using Javascript with objects, arrays, and for loops all over the place would be a nightmare. It would feel like a kludge.

    Javascript is not the ultimate language. Nor is SQL, C++, C, or even Assembly. The purpose of a programming language is to translate human intention into something a computer can act on. Yes, depending on your needs, it may be difficult or impossible to do what you want with just Construct 2 events, and in that situation, you may need to move to Plugins so that you can code it in Javascript. But for the most part, Construct's method of implicit selection and foreach-style actions is a very powerful and more natural way of expressing intent for the sort of things we want it to do. It only starts to feel like a kludge if you insist on writing your events in the same style you would write Javascript code.

    Anyway, I hope you get my point. There are many ways to represent your intent to a computer, and depending on the language chosen, some intents will be easy to express while some will be hard. I always recommend learning more languages (C, Java, Javascript, Lisp, SQL, RegEx) so that one can have a broader understanding of what tools we have available to us as programmers.