Cowdozer's Recent Forum Activity

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

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • 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.

Cowdozer's avatar

Cowdozer

Member since 6 Feb, 2013

None one is following Cowdozer yet!

Trophy Case

  • 12-Year Club
  • Email Verified

Progress

13/44
How to earn trophies