Ruskul's Forum Posts

  • There is indeed!

    If you are simply replacing the graphics, you can double click the sprite and load the graphics in.

    If you created a new sprite that has a different name and you want to replace the other sprite with the new one and the old one has events associated with it then do the following:

    1. Back up your project.

    2. Go to your event sheet(s) and search for events using the name of the sprite you want to replace.

    3. Highlight all events that are returned and right click them

    4. Select replace object. Choose the object you want to replace and then choose the object that is replacing it.

    You need to make sure the new sprite is exactly the same as the old one. This means it has to have all of the same variable names, behaviors, applied effects, and so on. Construct will only allow you to replace objects if they are identical (besides graphics and collision polygon... but you would need the same number and names of image points too (I think)).

    Anyway, best of luck! I hope that helps.

  • codah - they would be objects that inherit the behavior of the compound object

  • Aphrodite: So it is okay to use them so long as they get renamed? That's okay then. I thought Ashely meant not to build off of them period. I understand why but I didn't know if what I had done was not the right answer for the problem.

    I know others would disagree, but I would be happy to see cocoonJS go if it meant potentially getting more out of box2d in construct. But, as I am a pc only developer, I feel like my say is one sided.

    Thanks

  • Okay folks... this might be an impossible question...

    I want to create a compound family object.

    Each character in my game has the following objects:

    1. CharacterSprite (the animation object)

    2. CharacterCollider (with physics behavior attached)

    3. CharacterState (checks for collisions up, down, left, and right. Also checks what direction the character is going relative to the direction of gravity. Using all of this the object sets flags for such things as "inAir" "Onground" and "OnLeftWall"

    4. CharacterCollect (an object used to test for collisions with collectables and powerups)

    5. CharacterHitBox (an object to test for collisions with objects that can damage it)

    I also have a few extra objects to manage the butload of variables and constants needed for functionality.

    All of these objects have to communicate with each other, but regardless of what the character is (fish, turtle, or bird), the character state will always do the same thing, but I need to know what its state is before I can tell it to fly. Setting this stuff up for every character in a game with dozens is tedious, repetitive and time consuming.

    I can also say that I could write this up in C# using OOP with no trouble but I can't figure out how to do it in construct without being able to derive objects from one another. any ideas?

    I thought about just creating a family for each type of object in the compound object and another family to rule over them, but then I am still left with creating a bunch of objects manually.

    Thanks,

  • So... I'm guilty here... but in my defense there wasn't much of an alternative - at least not that I can see.

    ...Construct 2 has good built-in physics.

    ...Yes, but at the same time... no.

    physics support in construct 2 is limited when compared with box 2d. I need kinematic bodies and prismatic joints (basic and very much needed box2d functionality). I have been basically told that these features will probably not officially make it to construct 2. I edited the official behavior to expose this functionality. It took like 2 hours, and that was knowing nothing about behaviors and javascript. It works just fine and still does.

    How else can I make this happen if not by altering the official physics behavior?

  • Create 2 objects: the actual bar and the area the bar sits in. These should be created in a layer with parallax set to 0 (so these objects won't scroll). The bar needs some instance variables as well (IsClicked)

    Then add the following events:

    If bar clicked ----- set bar.IsClicked to true

    if mouse click released && if bar.IsClicked = true ------ bar.IsClicked = false

    If bar.IsClicked = true ------ set bar position (self.x, mouse.y)

    EveryTick --------- Scroll to position (scroll.x ,( bar.positionY * some scale factor))

    Because you have the scroll bar in its own layer that does not scroll, it should remain in place regardless of scroll. Some scale factor, if set to 1, will scroll as far as you move the bar. I would set this to 2 or 3 depending on how far you need to scroll.

  • A quick hack to solve it would be to create an instance variable on the family of objects you are using the editor to create. The variable would be a boolean IsPlaced (defualt is false). when you close a menu and hide the objects, check IsPlaced before setting their transparency. When you place an object set the flag to true. Does that make any sense?

  • There are no tutorials that I am aware of but the answer is quite simple.

    You know the problem, so try and think how you would solve this. I know of several solutions.

    The first thing you could do is create a family that contains all sprite graphics. At the start of a layout, for each object in the family you could set its z order based on it's y coordinate. Any object that moves around (such as the player) you could put in another family and label it mobile sprites. Every tick in the game you would change the z order of objects based on their y position.

    The second method would be to have two layers surrounding a character layer. For every object that can be walked behind you would split in half, putting part of it in a layer above characters or below, depending on what part of the object it is. This works well for grid based games where you can never be in front of a part of an object that you could also be behind. I think older games used this method but I am not sure.

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

    As for collisions, you need to create a polygon that allows the player to walk behind an object if that is what you want. A tree, for example, that was 64 pixels high may only have a collision polygon that is 32 pixels high.

    Hopefully this helped.

  • Is there a difference in the following events:

    For Each BulletObject: ----------- Subtract dt from BulletObject.Life

    ...compared to...

    Every Tick ---------------------------- Subtract dt from BulletObject.Life

    They seem to do exactly the same, and in used in such a basic manner there seems to be no difference. Does one use more overhead? I always heard that "for each object" could take time to loop through, but isn't that the same as looping through the list of picked objects?

  • Hey Everyone,

    I have been doing a lot of work to understand how physics works with construct. Basically trying to figure out all the things that the manual doesn't tell you. Things like this:

    Velocity = Impulse/Mass * 2500

    Velocity = Force/Mass * 2500 (time)

    AngularVelocity = Torque/Mass * 648.78892733564 (time)

    Change in velocity = -Current Velocity * Linear Damping Coefficient (time)

    ...and other stuff, such as the difference between "set velocity" and using forces or impulses. There is also some order and logic peculiarities due to the Construct 2 update cycle.

    I wrote more about it here ->

    https://www.scirra.com/tutorials/1135/physics-the-rest-of-the-manual

  • Thanks codah - This is good to know. I'll see if that fixes the problem

  • I spent several hours trying to recreate the problem, but I couldn't. It exists in my main project though. This is crazy. More digging around to do!

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • shinkan - HOLY FLIPPING Barbequed PANCAKES!!! YOU ARE right! I have been lamenting over that and struggling in the debugger for a while. Thanks for pointing that out.

    do you know if you can control max fps? Most of the time my laptop caps at 40fps but for a while it was 60 off and on?

  • LittleStain -Small variations occur when using dt (Like really, really small). In a physics simulation puzzle game this small fluctuation in dt can produce a chain of events that compounds to produce a drastically different result than was acquired last time the exact same thing was done. In these types of games, using time frame independent physics doesn't make sense.

    dt is calculated based on how long the last frame took. The current frame might not take that long - but in the end it averages out to 1 every second. The variation from frame to frame could yield results that vary, but we are talking minute fractions of 0.02 (depending on framerate). In reference to the above situation, this could be undesirable. But in a game such as asteroids with physics, this variation in dt is largely irrelevant. As far as the game goes and feels everything is still "predictable".

    My tests involve a simulated force of gravity acting on an object and an impulse based jump. The degree of variation in using dt in time-frame independent physics in my test is relative to what dt is and not a small difference. In other words, as the framerate increase, the force of gravity acting on the object increases over time. As frame rate drops, the force of gravity lessons over time. This indicates that dt is already applied to the physics internally and needs not be applied again. If you cut frame rate in half, gravity decrease by half.

    When running framerate dependent physics, frame rate only affects our perception of time passing but doesn't affect the actual game. If you apply dt to this model of physics you can get the same result as was described above, though "time" to reach max height after impulse was different, the height was still the same. I used impulse vs force to be able to compare maximum height obtained when applying a force in the opposite direction. I did this to take "human perception of what is happening" out of my experiment.

    If you remove dt from timeframe independent physics calculations within the event sheet, you get the expected results; that is, regardless of framerate, the object reaches the same "highest point" in the same "real time" after leaving the ground under an impulse and affected everytick by a constant force.

    This is in CONTRAST to what the manual states, indicating either an error in the manual, or an error in the implementation of physics in construct. My hunch is that the manual should be changed to reflect the actual state of box2d in construct.

    ....and by the way, just for clarification... I have worked with box2d outside of construct2 in other applications (XNA in C#, Unity in C#, Torque C++) and I have also read most of the box2d manual and understand the API in addition to reading a lot of the source code and understanding the theory behind collision detection in box2d. I have rolled my own collision detection before. Don't think I am speaking out of ignorance. I posed this problem as a question because I believe Ashley is a very competent programmer (and a wizard) and I looked for input and guidance before outright saying I found a discontinuity between Box2d/Construct2internal/Construct2 Manual in case I am wrong/confused. The more time passes and the more I tinker with this the more I believe that If Ashley says to use dt in events with timeframe independent physics then there is a "bug"; If he says not to use dt then the manual needs to be updated for clarification.

    I would find it odd that I am the first to find this problem but it seems that may be. In any case it is really difficult to test due to lack of frame rate control. I had to spam thousands of objects in order to get a drop in framerate to test changes.

    Also I may have found a bug in timescale and physics (when timescale is 0, force is still applied everytick in a building manner, such that when timescale becomes greater than 0 all the force added to the object over the last frames is added all at once in one frame... but I need to run further tests.

  • codah - that is a good workaround! ... I general I have tried to stray away from global constants as they can quickly bloat the editor with a lot of stuff. To keeps things organized I create holder objects for variables. I would probably create an object called Function strorage or something. I have alot of objects whose sole purpose is to aid in organization.

    example:

    Player_Physics (is the actual collision object with the physics behavior)

    Player_State (tracks the players states such as in air, on ground, etc)

    Player_Abilities (tracks the players upgrades and potential upgrades, like fireflower or star power in mario)

    Player_Constants (a storage for unchanging variables such as walk speed, run speed, etc

    Player_CurrentStats (a storage container for tracking variables such as current max speed, jump pwer etc)

    Player_IsSwimming_collider

    Player_inventory

    Player_expandedMath (such as old position, vector maths, and so on - provides a way of knowing projection vectors and velocities in a direction other than x,y)

    Global_PhysicsConstants

    Global_currentPhysics

    Global_GameManager

    Level_State

    ...and on and on the list goes. Storing all those things as an event variable would be cumbersome to deal with. Keeping them all in one object, like all the player stuff in player would be a hassle too. Plus the player as well as many other in game objects are much more than one collision box.