Yann's Forum Posts

  • demo: https://dl.dropbox.com/u/23551572/C2-Ga ... index.html

    capx: ninjaStroke.capx

    polygon plugin: polygon.zip

    polygon plugin topic: http://www.scirra.com/forum/topic62075.html

    should work with multi-touch but I have no devices so I couldn't test

  • Without force own texture, imagine that all your objects are gathered in one layer (respecting the their layer repartition for z sorting) and then rendered

    If a layer has force own texture on, their object will be kind of baked into one canvas, and then this intermediary rendering will be used instead of the objects (this intermediary rendering is what makes using force own texture slightly slower)

    The consequence of that, is that effects are limited to one layer. If you burn hole you can, in a way control which which object you will affect this way.

    In your implementation, you put an effect on the entire layer, so it will be applyed to everything underneath.

    If an object is in Destination-in, everything underneath its transparent pixels will be erased, else revealed.

    Since your layer is mostly transparent except for the few light sprite that are on it, only what's under your light sprites will be revealed, else you'll see the background of the HTML element containing the C2 canvas (gray in the preview)

    You see black in the editor, it's because it's the color of nothing (:

    destination in totally erased eveything on the viewport.

    Try changing the background color of your Lighting or Background layers you'll see nothing will change, the black isn't the color of your Lighting layer (how could it be, it's a transparent layer (: )

  • Hey neat art :D

  • That's php.

    If you have a server that runs php you can create a file name for instance

    list.php

    you copy/paste this code in it

    you put this file where the images are

    and you modify event 2 to call list.php instead of list.txt

    The php script will just look into the folder it is in, list all the files with extension, png, jpg, gif, or bmp like they are in list.txt (one file by line)

    It's just more automatic. It facilitate update since you'll just have to add images in the folder.

    However you'll have no control over ordering. (I don't know if the script orders alphabetically, or by date of modification...)

  • easy peasy... updated

  • imageViewer.capx

    A basic example with Canvas plugin

    you need to put a file named list.txt in the folder IMAGE_FOLDER (by default 'gallery') relative to your index.html

    In this file, you should have the list of images like that:

    myImage1.jpg
    myImage2.jpg
    myImage3.jpg
    ...[/code:2yju6fwg]
    they should be in the same folder as list.txt
    
    Then it should work like that:
    [url=http://dl.dropbox.com/u/23551572/C2-Games/ImageViewer/index.html]http://dl.dropbox.com/u/23551572/C2-Gam ... index.html[/url]
    with list.txt
    
    Using canvas was the only way to avoid reloading the image each time since you can't have different texture per instances of a sprite.
    The alternative idea was to set enough blank frames in the image sprite and load your image in each of them.
    But using canvas you can have any number of images, you'll just have to upload images and update list.txt without having to worry about re-exporting a capx.
    
    And if you need a php script for automatic listing, that should be enough:[code:2yju6fwg]<?php
    $imageDirectory = '.';
    $allowedExtensions = 'png,jpg,gif,bmp';
    
    $dir = opendir($imageDirectory);
    $ext = explode(',',$allowedExtensions);
    
    if ($dir) {
        while (false !== ($entry = readdir($dir))) {
             $info = pathinfo($entry);
             if (in_array($info['extension'],$ext)) {
                echo "$entry\n";
            }
        }
        closedir($dir);
    }
    ?>[/code:2yju6fwg]Yann2013-02-09 21:51:05
  • In the console you can read:

    XMLHttpRequest cannot load http://www.mattepainting.be/index.txt. Origin http://mattepainting.be is not allowed by Access-Control-Allow-Origin

    try to put the index.text in the same folder as your "game" maybe (: (and change the url queried accordingly

    The other solution would be to create a .htaccess with the proper things in it to set Access-Control-Allow-Origin properly. But it's not a good thing security-wise.

  • Don't use AJAX.LastData as a tag (:

    And also, I'm not sure that the On created is triggered if the object already exists in the layout

    Try

    On start of layout:
    [ul]
    	[li]> request "http://mattepainting.be/index.txt" tag "aSimpleString"[/li]
    [/ul]+AJAX On "aSimpleString" completed
    [ul]
    	[li]> Textbox: set text to AJAX.LastData

    Also by renaming index.html to run.html you break a reference in the offline.appcache manifest.

    You should either keep the index.html name or modify it inside the manifest.

  • Functions.Call("Srand",20,90)

    Your function name is just the first parameter of the Call() function of the Function object (:

    If you use this though the return value can be directly assigned to a variable

    -> System: set myVariable to Functions.Call("Srand",20,90)

    The other way to do it is

    -> Function: Call "Srand" (20,90)
    -> System: set myVariable to Function.ReturnValue
  • As far as I'm concerned, I don't like working with too many layout or event sheet.

    I only duplicate event sheet if a part of my code needs to be reused in more than one event sheet (which rarely happens)

    OR

    If I'm making a series and I have a common part and a variable part. This way I can use .bat files to always keep my common part in sync with the series (of course using the save as project for everything)

    I use groups where most people use tonnes of event sheet. To organize code.

    And sometimes, because it's easier, I use activation/deactivation. But I don't like it too much since I'm never quite sure I won't rename a group and then break these actions at some point.

    Anyway the advantage of groups over event sheets to me, is that you can do

    - a rightclick > collapse all to have a better view of all the part of your code and quickly access them.

    - you can be more descriptive with a group (like what it does and then in description I often put a list of the function definede inside that group)

          - it's easier to read than tab names when there's a lot of them

          - it's also easier to do a search on all your events if you only have to search one event sheet. For instance, if I want to see where a function is called (because I want to add or remove an argument), I just type the name of this function in the search bar and I can quickly access all the references.

    Now as far as code goes:

    • I put everything under functions. This way I always know and control when a part of code is executed and I avoid most problematic ordering issues. The only things I don't use functions for are:

          - things that should happen or be evaluated every ticks

          - things under triggers (on click, on key press, etc) though I often call functions from there like "Button: on click -> Function: Call Button.action() with action an instance variable containing the name of the function to call.

    • I use global variables sparringly. For the same reason. If you modify global variables in two different areas of your game, you have to always keep track of when things happen. It's asking for trouble. Also polluting the global scope is a pain (too much thing in combobox menus)
    • Instead of global variables, I use a lot of static local variable. They behave the same but since they are scoped I'm sure they are modified only inside their limited scope.
    • I avoid like plague what is called "magic numbers". A magic number is any number you use in an expression. There are two reasons I avoid them:

          - first, they doesn't mean anything by themselves. What does 1.73 means? Nothing.

          - Second, they may change during your development. For instance if you have a grid based game and at some point you find out that the size of the grid is wrong, you'll have to change all the expression where the width and height are used.

    • I use constants a lot! Mainly to define most magic numbers. This way I can do Global constant number MY_HEIGHT = 1.73. I even do something like TRUE = 1 and FALSE = 0 and I also name array indexes like X_ = 0 and Y_ = 0 (the underscore is here because I often use x and y as temporary local variables)
    • Constants can be global since they can't be changed. But using local constant can be a good idea since you limit global scope pollution.
    • I always write my function in subevents of the "on function" event this way they collapse more nicely, and I add a little comment on top explaining what argument they take and what they return (if it's not obvious). This way I can forget how they are implemented (abstraction).
    • I use only one "on start of layout" event and I put it on top of the event sheet. Rarely in a group.
    • I agree with squiddster, I try to use as less object types as possible. For instance I use only one Button object and I do what I explained above "Button: on click -> Function: Call button.action()

    I talk more about my practices in my C2 Channel by the way. I'll soon start a RPG series where amongst many other things, I'll show you how I handle the problem described by sqiddster:

    "Have your layer setup fleshed out before making the first level of a game with many layouts. It's incredibly boring to mirror layer changes across 50+ levels. (@Ashley this seems something the engine could well improve upon.)"

    Which is something I try to avoid, it's too hard to anticipate all the layer you'll need, you kind of lock your development too early in my opinion.

    I fell into the "mirror layer changes across 50+ levels" trap.... Never again! Yann2013-02-08 05:16:17

  • Hey thanks guys (:

    I made a little erratum video

    There was a little bug creeping in the dark :3

  • The spawn action is an object action, the create object is a system action.

    The consequence of this design, is that if you call the spawn action each picked object will spawn something

    The second difference is that the spawn creates an object at the position of the calling object.

    In short, spawn is equivalent to:

    foreach object -> create object at object.X, object.Y

    As far as retreiving UIDs, you shoudl be able to do it like that:

    -> Create/Spawn object

    -> set variable to object.UID

    For IIDs I don't know exactly when IIDs are assigned and/or reevaluated. But usually, since there shouldn't be any "hole" in the IIDs the one attributed to the newly created object should be equal to object.Count. (ie: if you have 3 objects they probably have the IID 0,1,2 so the next one will be 3)

    But you shouldn't rely too much on IIDs, I don't exactly know when they are assigned or recalculated, and with so much imprecision you really should use your own indexing (with your own instance variable), and C2 could change their way of doing things. IID are good for temporary uses or when the state of instances don't change.

    When there's creation/destruction involved, you're better off handling things yourself or using UIDs.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Thanks (:

  • TELLES0808 You're welcome (:

    Two new series of video on my polygon plugin

    • Polygon Plugin:
      1. Polygon Splitting:

        Enjoy :D

        I decided to stop posting the twitch links, since the videos are unedited.

        But if you are curious to see the rough product of my screencasts, you can still see them on twitch (:

        And subscribe on twitch if you want to be warned when I'm broadcasting. You could ask some live questions (:

      2. Link to .capx file (required!):

        accessingLocalConstantVariables.capx

        Steps to reproduce:

        1. create a group

        2. create a local constant inside the aforementioned group

        3. create an event that reads this variable (ex: on start of layout -> Text: set text to LOCAL_CONSTANT)

        4. run the preview

        Observed result:

        If you open the console, you should see the following line:

        "Check: local var stack holds undefined value"

        Expected result:

        Nothing. But it's a problem when you have such access constantly in different places since it will flood the console.

        Browsers affected:

        Chrome: yes

        Firefox: unchecked

        Internet Explorer: unchecked

        Operating system & service pack:

        Windows server 2008 r2 SP1

        Construct 2 version:

        r117

            Yann2013-02-01 19:00:54