Yann's Forum Posts

  • For a dungeon algo you better use the array. I did a cave algo a while ago, trying to be smart I only used sprites by filling the layout with them and then digging into but it's way slower.

    Handling cols*rows sprite is slower than an array of cols*rows data because sprites are big objects

  • destroyCards.capx

    The main issue was to set the Array size to (0,1,1) not (0,0,0).

    Because, if it's (0,0,0), your Array has no dimension and the push function doesn't "know" if you need to push a single element, a row or a 2D plane.

    It's how I understand it.Yann2012-07-05 03:37:46

  • because action works on what is picked in a condition.

    you should do something like

    Array: foreach X element
     Sprite: pick by UID Array.CurValue
       -> Sprite: destroy
  • Usually to handle fire rate stuff I do things like that:

    global number firerate = 0.4. // in seconds
    global number firetimer = 0
    +every ticks
      -> set firetimer to max(0,firetimer-dt)
    +on space pressed
    +firetimer = 0
      -> set firetimer to firerate
      -> create bullet
  • hmm I think you didn't implement it completely.

    doing data.replace("\r\n","\n"); only replace the first occurence.

    it seems you need the g flag for a global replacement as specified here

    data.replace(/\r\n/g,"\n"); works

  • nah you're doing it wrong

    first you don't use dt in the wait as it's already in seconds

    seconds don't create and destroy but toggle visibility

    third, well you might have the free version, but I'd use families to make things more code friendly (:

    Also I would use a timer variable something like

    Global number speed = 5 //frame by second
    Global number t=0 //timer variable
    Global number frameCount=3 //number of "frame" for the effect
    Every tick 
      -> add to t speed*dt
      -> tiledbg1: set invisible
      -> tiledbg2: set invisible
      -> tiledbg3: set invisible
    int(t)%frameCount = 0
      -> tiledbg1: set visible
    int(t)%frameCount = 1
      -> tiledbg2: set visible
    int(t)%frameCount = 2
      -> tiledbg3: set visible
    

    With family (myTiledBG), I would add a family variable named 'frame' of type number and manually set for each tiledBG in the family a number repr?senting the frame.

    And then in event it would look like

    Global number speed = 5 //frame by second
    Global number t=0 //timer variable
    Global number frameCount=3
    Every tick 
      -> add to t speed*dt
      -> myTiledBG: set invisible
    myTiledBG.frame = int(t)%frameCount
      -> myTiledBG: set visible

    As for perf, well, there shouldn't be any difference with animated sprite. That's more or less what they do, swapping texture. But yeah you'd have a little bit more object to handle, if it's less than let say 50 frames it should be ok.

  • Hi,

    Step to reproduct:

    • create a new project and save it (important)
    • add an AJAX object
    • import a file
    • set a Request project file action using the imported file
    • rename the file in the project panel

    -> you can see that the name isn't updated in the event sheet

    • ctrl+S
    • try to reopen the capx

    -> you can't reopen the capx, en error message is triggered

    Failed to open project '\\...caproj\':
    Project file missing from project
    etc
  • You can create as much object as you have frames and swap them during runtime :D

    A big pain but that should work

  • Ashley yeah I see your point and I agree (: I just think there should be something that can be used when for instance I start typing the name of a custom function and then I can see how many parameters it needs.

    I thought that this way you could write "str2map(" and then see a tooltip of your parameters.

    aridale not really, functions not only isolate part of the code, but can be triggered many time on one event loop. Groups can't really. You could put a "repeat counter time" on your event with counter as a number variable that gets incremented each time you need to call the function, but then you'd have to keep the parameters in an array or a dictionary, and then store the return values, and then wait for the next loop to use them... pretty heavy...

  • Hi,

    To find linebreaks (newline) on a project file I called via the AJAX object, I had to modify the plugin this way:

         Exps.prototype.LastData = function (ret)
         {
        var str = this.lastData.replace(/\r?\n|\r/g,"\n");
              ret.set_string(str);
         };

    Dunno if I did it well enough but it seems that newline is only an alias of the js "\n"

    But in windows I think linebreaks are a "\r\n" and the tokencount function gave me an extra character from the same string when I loaded it from a project file.

  • zsangerous

    Nah my example is the simplest possible stuff you can do with function.

    Functions in CC at least are pretty powerfull.

    Some month ago I made a level editor in CC and I created "save" "load" and some other usefull function for my editor.

    This way I could do a save anywhere in my event cheet, on click on a button, on a keyboard shortcut, when I change level "save" on the current before changing, etc

    Really missing this functionnality. (well as I said, not exactly missing since there's rex's plugin (: )

  • zsangerous if you used Construct Classic, there's a function object.

    This object allows you to encompass some actions inside a function call this way

    Function: on "add"
      -> Function: return Function.param(1)+Function.param(2)

    This way anywhere in the event sheet you can do a:

    -> Set myVar to Function.add(5,4)

    and myVar will be equal to 9.

    I hope C2 will have his own function system soon, but for now, rex's function plugin seems to do the job well enough.

    I just had this idea about function I wanted to share. Because I don't really like the way functions are lost in the event sheet in Construct Classic.

    It's super easy this way to have some repetitive part of the code called from anywhere and instantaneously executed. Functions are better than using a trigger variable or groups because they are kinda out of the main event loop.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Hi,

    As I'm making a level editor, I'm starting to really need a function feature.

    I know, it's on Ash's todo list, and there's a plugin rex made and I'll probably give it a try.

    But then I thought about how a function could work inside of C2.

    I always thought that how it was made in CC was kinda awkward.

    Putting function anywhere inside the main event sheet, it feel like it isn't their place.

    So, what if, functions where a kind of hybrid between event sheet and object.

    It would be a kind of event sheet, stored in a project folder but an event sheet which could have properties.

    And some of these properties could be function parameters.

    For the inside of the function it would look like an event sheet but where you can access these parameters like global variables. (and still access global variables)

    It could look like that

    Link to big image

    <img src="https://dl.dropbox.com/u/23551572/C2/Functions/mockup.jpg" border="0">

  • Hey there

    I got a js error saying

    Uncaught ReferenceError: newheight is not defined commonace.js:208

    Going through the commonace.js, I found this:

            acts.SetHeight = function (h)
            {
                if (this.height !== h)
                {
                    this.height = newheight;
                    this.set_bbox_changed();
                }
            };

    I'm almost certain it should be instead:

            acts.SetHeight = function (h)
            {
                if (this.height !== h)
                {
                    this.height = h;
                    this.set_bbox_changed();
                }
            };

    After changing, the bug indeed disappeared into nothingness (:

  • I think it's expected since the choose(2,6) is evaluated each tick.

    To hold during 6 seconds the choose(2,6) would have to return 6 each tick

    You better do a

    Global number rate = 0
    On Start of layout 
      -> Set rate to choose(2,6)
    Every rate seconds 
      -> Set rate to choose(2,6)
      -> do things