cacotigon's Recent Forum Activity

  • 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#.

  • okay, thanks, that clears it up for me. I see what you're saying Kyatric, organizing events which pertain to a object through that object's conditions in the event sheet helps with readability/maintainability. Thanks Ashley about trying to use less System events.

    Back to coding!

  • Thanks! That's good to know about rotations. I'm so worried about performance that rather than doing opacity/transparency/etc in real-time for example for particle type effects, I was considering just creating individual frames in Paint Shop Pro using various effect filters and exporting as a tile-set. :)

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • I've got some enemy sprites which are moving around by using Platform behavior and simulating the left and right key presses.

    However, I realized in the event editor I can use either:

    On System.Tick

    if(Zombie instance var 'facing' = "left") simulate keypress left

    if(Zombie instance var 'facing' = "right") simulate keypress right

    or I can simply do a 'Compare instance variable' event:

    On (Zombie instance var 'facing' = "left") simulate keypress left

    On (Zombie instance var 'facing' = "right") simulate keypress right

    Can anyone outline the difference between these from a performance perspective? Which one would you recommend?

    Thanks,

    -- cacotigon

cacotigon's avatar

cacotigon

Member since 10 Mar, 2009

None one is following cacotigon yet!

Connect with cacotigon

Trophy Case

  • 15-Year Club
  • x2
    Coach One of your tutorials has over 1,000 readers
  • RTFM Read the fabulous manual
  • Email Verified

Progress

18/44
How to earn trophies