cacotigon's Forum Posts

  • Kyatric, as I mentioned before, this code is from a much larger project, one where I initialize several different arrays, each containing different information. Sorry, can you explain what SOL means? Thanks for the info about the function plugin, I will try removing it and seeing if the same problem occurs.

    Yann, that seems strange, especially since I can access the arrays class properties immediately after create object including the UID, which would seem to indicate that the object has been already created. Unfortunately, if I make this change, my code order is going to get messed up, I guess I might have to make a IsReady var and group everything else under.

    I'm still kind of unhappy about this, in normal Construct behavior, after you create an object, any further commands will act on that object essentially an automatic pick operation occurs, so why doesn't a deliberate pick work? So frustrating.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Oh I know that, I create objects on layout start and then save there UID values into associated global vars.

  • I'm so frustrated I feel like punching a baby.

    Can anyone please tell me what the heck is going on with this code? A pick operation is not picking *anything* even though the UID is valid and the object type is correct.

    I'm seriously about to cry, I've been at this for the last two hours.

    Here's the capx for anyone who could shed some light on this...

    (It's pretty simple)

    Pick failure project

    I gutted the project file so that it would be a small capx download, cause this originally comes from a much larger project.

    Help me obi-wan kenobi, you're my only hope (bends over really ackwardly)

    -- cacotigon

  • Just to give everybody a heads up in case you want to copy some event sheet code between different projects, it might not show a warning message, BUT trust me, DON'T DO IT.

    If you attempt to copy over an event sheet that contains references to objects which don't exist in the current project, Construct will warn you about that. When that happened, I tried to create the objects which were referenced and give them the same names, and then copy over the event sheet. At that point, Construct didn't throw any warnings or errors, everything looked just fine, the entire sheet copied over, and it looked like I was going to be saving some serious time, since I've got a lot of projects where certain event sheets (which I essentially use as containers for each respective sprite's logic) were nearly identical.

    Fast forward to almost two hours later, where some of my scripts just weren't executing properly, and I finally narrowed it down some pick events were not matching known UID values, meaning that even though they appeared to be doing a pick on the same object as the last project with the same name, they obviously contained some address references that were different. Both the Pick operation code and the Create Object code was stuff I had copied from the aforementioned project's event sheet.

    After re-creating the aforementioned picking and associated create object commands from scratch, the code worked. Anyways, this is just a heads-up to anyone thinking of trying to open up multiple projects in the project tab and trying to copy over event code. As it stands now, unless you really ENJOY putting tons and tons of Append Text statements in your code, I wouldn't recommend trying it.

    -- cacotigon

  • Hey R0J0hound, thanks for the link. I went ahead and implemented that in my code. Works great!

  • Just some observations and suggestions regarding keyboard shortcuts.

    The keyboard shortcuts outlined in the keyboard tutorial such as Add Action (A), Add Blank subevent (B), and Add Condition (C) don't work unless a condition/event/action is first highlighted with the mouse. Unfortunately, you can't navigate within the event sheet using tab / arrow-keys, unless you have clicked and highlighted, this seems to defeat the purpose of a hotkey, since I have to use the mouse in the first place. And after every event/condition/action creation, the event sheet loses focus and I have to click inside of it again.

    Another similar thing happens when you bring up the Add Events or Add action box, the cursor is automatically in the 'Search box' which is a very useful feature for quickly finding the right event / condition, unfortunately, let's say I type 'time' to only find the time actions under System, now I see four different options, but you can't use the arrow keys to navigate down there, you can't even tab down to it, so I have to type in the full beginning part of the name and narrow down the 'results' to 1 before I can hit the 'enter' key and proceed.

    Small things like this, especially for a keyboard warrior like myself would really help to maximize our workflow. I know the idea of Construct is to try to get away from scripting, but I think keyboard navigation would be really useful for those of us with netbooks, etc when we don't have a proper mouse available, etc.

    The first time I used Construct, it felt like I was playing Diablo, I had to click the mouse so many times. :) A while back I suffered from tendonitis primarily from excessive mouse usage, (I know I know play me the violins), but it would really be great if we could minimize the amount of mouse usage.

    Thanks a lot!

    -- cacotigon

  • I encountered a strange bug where creating a new object of array resulted in an array with no properties (Width, Height, Depth). After doing some more research into it, I've narrowed down the steps to cause it to occur:

    Steps:

    1. Create a new project

    2. Bring up the event sheet tab so that the Event sheet is active (as opposed to the layout)

    3. Right click Object Types and insert new object Array.

    4. Array will contain no properties, and under the Layout xml inside the capx file, the no-world instance xml will be blank <nonworld-instances /> instead of containing something like:

        <nonworld-instances>

            <instance type="array">

                <properties>

                   <width>10</width>

                   <height>1</height>

                   <depth>1</depth>

                </properties>

            </instance>

        </nonworld-instances>

    If the layout is the active tab at the moment of creating a new object array then the problem doesn't seem to occur.

    I've also included a sample capx project file with an incorrectly added array.

    Add Array Bug Project

    Hope this helps!!!

    -- cacotigon

  • Here are my system specs:

    Windows XP SP3

    Intel Centrino

    Geforce 6800 Go

    Chrome 17.0.963.38 beta-m

    Construct 2 r76

    The message itself:

    ---------------------------

    Construct 2 Check failure

    ---------------------------

    Check failure! This is probably a bug:

    Cannot find file on disk to return over HTTP

    File: C:\Documents and Settings\shaun\Local Settings\Temp\c2-2OUFKE\html5\preview.html

    This can indicate project corruption - please notify Scirra of this problem with the steps you were doing immediately beforehand.

    Condition: false

    File: HttpFileServer.cpp

    Line: 295

    Function: void __thiscall HttpFileServer::ServerRespond(struct _HTTP_REQUEST_V2 *)

    Build: release 76 (32-bit) checked

    Component: HTML5 exporter

    (Last Win32 error: 3)

    You are using a 'checked' release of Construct 2, intended for testing, which causes certain errors to be reported this way. Hit Ctrl+C to copy this messagebox - it's useful information for the developers, so please include it with any bug reports! Click 'Abort' to quit (unsaved data will be lost!),'Retry' to turn off messages for this session and continue, or 'Ignore' to continue normally.

    ---------------------------

    Abort   Retry   Ignore   

    ---------------------------

    The project file:

    Blank project

    Notes:

    I did some testing to try to narrow down when this occurs, and I can get the problem to repro consistently. I've included the capx file that I did it with as well.

    Steps:

    1. Open Construct

    2. Create a new project (or open an old one, happened in either case for me)

    3. Save it as a capx

    4. F5 to Chrome window

    5. Close Chrome

    6. Close the Project in the Project tab but leave Construct running

    7. Attempt to access the server from my iPad, although most likely any access will trigger it.

    8. Construct 2 Check failure occurs

    Construct seems to leave the web server open even after I close the Chrome window, close Chrome entirely, and/or close the project. The server only terminates after I completely close down Construct itself.

    Hope this helps,

    -- cacotigon

  • Hi everybody,

    I'm having some trouble figuring out how to create a set of weighted probabilities easily in the event code. Let me outline what I have:

    if(EntityA is overlapping Trigger)

         Set EntityA.ExecuteSub = true; // this is so EntityA only runs the overlap code a single time.

         System.Create(EntityA)

         Set EntityA Animation (Choose("Animation1", "Animation2", etc))

         Set EntityA size

         Set EntityA Position

         Set EntityA localvar1

         Set EntityA localvar2

         Set EntityA localvar3

         Set EntityA localvar4

         Set EntityA Speed

         { ... more instructions involving EntityA }

    I have ten different animations in Entity A and it randomly selects one each time. However, now I want to weight the probability so certain animations are more likely to appear than others.

    I planned on setting a global variable called RandomNumber, and than basically being like:

    if(RandomNumber < 10) Choose (EntityA.Animation1)

    else if(RandomNumber < 25) Choose (EntityA.Animation2)

    else if(RandomNumber < 30) Choose (EntityA.Animation3)

    I have a feeling I'm going to have to create a new global boolean variable called RandomNumberMatched and then:

    0. Check primary condition overlapping

    1. Generate random number

    2. Spawn EntityA - and hope that the following subevents automatically refers to this one

    3. Write a bunch of Subevents under the primary event checking the Random number value as follows:

    Sub event:

    if (RandomNumber < 10)

         RandomNumberMatched = true

         EntityA.SetAnimation( EntityA.Animation1 )

    if (RandomNumber < 25)

         RandomNumberMatched = true

         EntityA.SetAnimation( EntityA.Animation2 )

    if (RandomNumber < 30)

         RandomNumberMatched = true

         EntityA.SetAnimation( EntityA.Animation3 )

    4. Rerun the rest of the set size,position,etc etc on this EntityA *AFTER* the subevent code has finished I guess putting the entirety of this code in a blank sub-event on the primary event.

    Without an if-elseif-else condition I have to use an additional variable to falsify the following subevents.

    I really hope there's a more modular way to encapsulate what would ordinarily be a fairly and I would think common thing to do in conventional OO coding.

    I wish I could just write a function

    GetWeightedString( ProbabilityArray, StringArray )

    which takes a list of numbers up to 100 returns the respective String in the array, and then I could just call a simple function that would Spawn based on the Object's name.

    Something like this:

    Spawn randomentity = GetWeightedString(new Array[2, 4, 8, 20, 25, 60, 80, 100], new String[EntityA, EntityB, EntityC, EntityD, EntityE, EntityF, EntityG, EntityH])

    Thanks everybody for your assistance!

    -- cacotigon

  • Thanks Yann, I took a look at the changes you made. I guess the use of PlatformIID makes isOnPlatform redundant.

  • Just a small note, I've updated the project file to support multiple platform instances using the index ID.

    Vertical Platforms Example Project

  • Whoops, I see that. Guess I'm not used to the way instances vs objects are handled in the event sheet yet. :) Thanks for the heads-up.

  • Hey Yann, thanks for the reply, I implemented the changes that I had outlined earlier in this post about manually controlling the platform and removing the Sine behavior altogether.

    I've also added an OnPlatform boolean which is checked before the platform is moved. This is recommended since if you have a fast moving platform, the next Y coord of the platform may already have carried it too far away from the player (especially when moving downward), in which case the subsequent 'check if feet overlap' condition will return false and the player's Y will not be aligned with the Platform's new Y, and the player will enter the falling state again.

    Here is a snapshot of the event sheet:

    <img src="http://i41.tinypic.com/2n1tjyc.jpg" border="0">

    EDIT: Picture is wider than I thought, so you'll have to scroll to the right to see it, sorry about that.

    As you can see in this screenshot, immediately after the platform is moved, the player's bottom Y is anchored to the Platform Top. This basically eliminated the problem I was having earlier with the sine behavior.

    Despite this, the event sheet still records the occasional on_fall and subsequent on_land triggers while riding the platform. I don't understand how this could be happening if the event code runs in a line-by-line interpretive fashion.

    FIXED!!!: Okay, I started logging the respective Y coordinates to see if I could narrow down the random fall-state detections. (in this instance, I'm referring to the Player's bottommost Y, and the platform's topmost Y). Being floating point numbers (and possibly due to pixel rounding???), they were off by ~0.5 whenever the jump-state happened. I decided to Math.floor my ManualPlatform Set Y event whenever the motion happened to see if this would fix the problem, and the problem went AWAY!!!

    Here is the final project file, which contains logging text fields, lots of comments, and instructions.

    Final Vertical Platform Project

    Final thoughts:

    A standard vertical platform has Construct built-in sine behavior. In normal circumstances, when the player is considered "riding" the platform, the Player Y would then be set to match the platform Y in the event code. The built-in sine behavior is responsible for updating the Platform Y moving it away from the Player Y . HOWEVER, this sine behavior logic does not happen in the event sheet. After Construct's Sine behavior updates the Platform's Y value, Construct's Platform behavior detects a gap between the Player and the platform and triggers the platform fall-state. All of this happens before the next event cycle, meaning we have no time to update the player's corresponding Y value to match the platform.

    Some things to note about the project:

    1.The way I've got it now, holding the Shift key will accidentally disable the platform attachment code, with ensuing hilarity.

    2. To change the movement behavior of the manual vertical platform, use the instance variables MaxMovement and MaxTimeToMove (in seconds, use longer values for slower platforms), StartingY is used by the system.

    Also, kyatric or another moderator, if you think that this information might be potentially useful to others, maybe we could add it to the [How to] Vertical Platforms forum post. I was also thinking about writing up my findings in a tutorial, if that could be helpful for the community.

    Back to work!!

    -- cacotigon

    NOTE: I originally had all vertical platforms classified under a VerticalStylePlatform family, however, I went ahead and removed it as I wasn't certain whether this would cause problems for people who had the free version of Construct 2.

  • Hey everybody!

    So I've been doing some experimentation with vertically moving platforms with the player sprite which has platform behavior and have been running into some problems. I did notice that there is a link to a vertical moving platform example in the[How to] section but I wanted to try to come up with my own solution before I looked at somebody elses, since I feel like this helps me get a better grasp of the Construct engine. I've narrowed it down to a very small capx project that contains some logging text fields to help keep track of events.

    Vertical Movement Sample Capx

    Basically my idea was:

    Player spawns a small "foot detection" block (no special attributes) directly below himself, and the 'foot' is then pinned to the player. When player's foot overlaps with the vertical platform (later I'm going to add more precise detection to determine that the player is colliding on the top of the platform itself), the player is considered to be riding the platform, and the player's bottom Y is continually set to the platform's top Y value. This works without any problems, the problem is that when the platform is moving downward and in the mean-time *between* setting the player's Y, and going through another ??TICK?? (looping through another logic iteration), the engine sets the player to be in a "fall-state", so the player platform behavior will not respond to a jump action.

    Do I need to control the platform's movement manually in the event sheet so that I can make it so that the player's Y is set to the Platform.Y *after* the platform has moved? I have a feeling that this might be part of it. It's just so nice to be able to use the Sine behavior to automatically control the vertically moving platform.

    Thanks a lot everyone!

    -- cacotigon

    P.S. Don't worry about the DefaultInstances layer or the disabled gravity code.

  • Kyatric thanks for that link; just finished reading it. I didn't realize that the Javascript garbage collection could be such a performance killer, provided I followed proper disposal practices, I never really had to worry about something like that before in C#.