Ruskul's Recent Forum Activity

  • Hey Everyone,

    Contruct 2 needs more hotkeys. Without them my APM suffers and thus my productivity, I'm sure yours douse as well. A major example is Adding variables to objects. Once the window is brought up you have to spend alot of time clicking around. Once you begin adding you shouldn't have to leave the keyboard... or at least that would be nice. Anyone else agree/disagree?

  • oosyrag I was leaning towards the way you do it for the same reasons you mentioned. I was just trying to think of the cons before I committed to that method. I generally prefer the method that a.) scales perfectly to any size project b.) is easiest in the long run (which usually means its fastest to work with).

  • Hey everyone,

    What are people's preference when creating assets (assuming you are creating mostly static bg elements). Do you create many objects and put them in families or do you create a single object and give it many frames and/or animations? Which way makes it easiest to create levels manually? What about generated levels?

    An example of this could be clouds in the sky. One could easily create 20 objects or just as easily create 1 with 20 frames or animations if they are animated.

    Why do you do it the way you do? What are the downsides and upsides to that method. I know a bit of this will come down to preference and that's okay.

  • JackieChan - Excellent, thanks for posting that. I figured I would overlook something. Changing the op to reflect this. I am also adding your link to the op for the edited behavior file if that is okay.

  • Colludium and - I had a talk with Ashley about this a year ago and he said that you would most likely hurt your performance rather than help it. The collision system is very well optimized at the moment. Also, the collision detection algorithm runs much better than checks you can make in the event sheet. In general simply asking if something is overlapping is a very fast check depending on circumstances. Now I can see managing objects so there are no collision checks off screen for some games... I have done this and gained performance because of that, but I had thousands of objects that needed to be checked. Disabling them once they were off screen was a good way to cut down the volume of checks needing to be performed. But I wouldn't worry about enabling and disabling collisions a few pixels from where it matters. Actually, if the bounding boxes aren't overlapping the collision check is super fast. You would basically be doing the same thing it already does, but more slowly because it is via events instead of jscript.

  • Hey JackieChan

    I finally posted how I've done this in the past.

    It involves coding, but no fear its a few simple cut and paste / change names style coding. This solution works like a charm for platform behavior solid filtering. R0J0hound and megatronx may like this as well.

  • Solomon

    Waltuo

    Zebbi

    I think you 3 mentioned that you'd be interested in this solution when I posted it. Sorry it took me so long to get around to it. Hopefully it is still relevant. (: Also Tokinsom , you might find this interesting as well. Colludium - I think we talked about this like a year ago lol.

  • Hey all,

    Have you ever wanted to have some characters using the platform behavior to collide with some solids but have others pass right through? I have a no nonsense solution to the problem. It involves modifying behaviors, so be prepared for that. I would love to put this all in a tutorial but for some reason it seems the new tutorial link is broken at the moment...

    If you are fluent in the sdk and c2 scroll down for the TLDR.

    Lastly, JackieChan has kindly provided a link to the modified behavior if you really don't want to touch the code. If you are a veteran coder and know your way around, this is fine, but I would strongly encourage the rest to try and learn why things were changed. The more fluent you can became at working in the sdk the more powerful c2 is. Plus you gain levels as a game dev! Skillz unlocked. The link is a few post down.

    Okay, moving on...

    There is a folder called construct 2 somewhere on your computer. Probably. It should be under program files or where ever you installed it. Follow this path -> Construct2 -> Exporters -> html5 -> behaviors. Inside the beahviors folder is one called platformer. Make a copy of this folder and name it something else ("MyPlatformerModified" for example).

    You technically don't have to make a copy, but any changes you make to a behavior can break existing projects if you are not careful. Thus we will make it a new behavior.

    In this folder there is a runtime file and a edittime file. Open both.

    If you were just modifying the existing behavior you wouldn't make the following changes, but it is super important to make them if you copied the behavior. In the edittime file at the top you should see the following:

    return {

    "name": "Platform",

    "id": "Platform",

    "version": "1.0",

    "description": "Jump and run between platforms (solid objects).",

    "author": "Scirra",

    "help url": "http://www.scirra.com/manual/100/platform",

    "category": "Movements",

    "flags": 0

    };

    You need to change "Platform" to whatever you named the folder when we copied it. Make it exact and make sure you keep the same syntax (spacing, quotes, commas' etc) Syntax in coding is like grammar. If you don't use it correctly the computer won't have a clue what you are trying to tell it. Its like a grammar nazi it won't do anything unless you speak correctly. You can also edit the author to indicate you have tampered with it.

    Next, go to the runtime file and look near the top. You should see this:

    cr.behaviors.Platform = function(runtime)

    {

    this.runtime = runtime;

    };

    (function ()

    {

    var behaviorProto = cr.behaviors.Platform.prototype;

    Change Platform in both places to the same name you chose earlier. Again, make it exact. Spelling and caps matter. Anywhere you find the following code must be changed:

    cr.behaviors.Platform.prototype

    to

    cr.behaviors.TheNameYouChose.prototype

    Make sure of course that the "TheNameYouChose" is reflects the behavior ID that you replaced earlier.

    Now that you have change everything to make this behavior indeed a different behavior all that's left is to change it.

    In the Runtime file search for the following line:

    behinstProto.posttick = function ()

    and change it with:

    Acts.prototype.platformupdate = function ()

    Basically posttick is function that is called automatically by construct every tick in the game. By changing this to platformupdate we make it our own function. Now it will only be called when we tell it to be called. This is important because we now can have control over when the behavior updates. I am sure you see the significance in this

    Now because we turned this into our own function, we need a way to call it. You notice that below the function line is an opening squiggly bracket {. There is a corresponding closing squiggly bracket for every opening bracket. We need to cut this entire function out from where it is and paste it in a new location. This will be lines 383 through 943. Its quite a large function, but it makes everything in the platform behavior "work" the way it does.

    Paste it under the following line of code:

    //////////////////////////////////////

    // Actions

    function Acts() {};

    Make sure you copied the entire function! from its name to the final closing bracket. You also don't want it left where it originally came from. so make sure you cut and pasted it and not just copied it. We added it to the section of code that is responsible for containing functions that can be called from within construct as actions. All that is left now is to add this action in the edittime file.

    Sear for the following lines of code:

    AddNumberParam("Jump sustain", "The new jump sustain, in milliseconds to sustain jump velocity for.");

    AddAction(14, 0, "Set jump sustain", "", "Set {my} jump sustain to <b>{0}</b> ms", "Set the jump sustain property.", "SetJumpSustain");

    Under it add the following:

    AddAction(15, 0, "Update", "", "{my} Update Platform behavior" , "Manually call the platform update function.", "platformupdate ");

    This is where our script interfaces with construct 2 events. Save everything and open a new construct 2 project to test this out!

    One last thing! If you are new to coding for c2, if you make a mistake, when you run your construct 2 project you will get an error. The error probably won't mean much to you, but it will give you a line number. Go to the code and look up that line number and you will find the mistake. With time and practice, fixing errors will become easy and fast. Also, you need to restart construct 2 every time you make a change to your script, other wise construct 2 won't load the newer version of the behavior. Check out the SDK in the manual for more good info!

    ---------------------------------------Construct 2 portion------------------------------------

    Inside construct 2 create a quick scene with some solids. Make sure you have a least two different objects that have the solid behavior. A red one a blue one. Add a red character and give him the new platform behavior. Add a blue character and give him the new platform behavior. Add one more character but make this one purple, give it the new platform behavior as well.

    At this point, if you run the game nothing happens. The behavior is identical in how it functions to the original platform behavior, but remember we need to call its update function manually now.

    Add the following events:

    EveryTick ->

    PurpleCharacter set action Update.

    BlueSolid Disable Solids.

    RedCharacter Update

    BlueSolids EnableSolids.

    RedSolids DisableSolids.

    BlueCharacter Update.

    RedSolids EnableSolids.

    There are much better ways of managing the turning on and off off the solids as well as updating the characters, but this should give you a general idea of whats happening. I keep my characters in families with a collision id variable. I also keeps my Solids in a family that has a collision id. I then enable or disable solids based on the ID and update all characters with the appropriate Id. Basically you can handle them all in groups and when you add a new character into the game you just have to give it the correct Id. You can change the character ID at anytime to allow it to pass some objects but not others. I use 0-7 for my Id numbers and use the id sort of like 3 bits. It is really neat what you can do with collision filtering and its disappointing that construct 2 doesn't handle this itself. I consider it necessary. You can use it to create Character that you can go through some walls while others can't. You can use it to make it so some objects only interact in the background layer and some the foreground layer. Ever played mutant mudds or xenodrifter? You can make the same effect in construct now. Yay. I'll move this to a tutorial once that works.

    Let me know if you have any questions!

    TLDT _____________________________________________________________________

    1.) copy the platform behavior folder and change it to be a new behavior.

    2.) Move the contents of the posttick function into a new function as an action. Create a corresponding action in the edittime file. I named it "platformUpdate" in mine.

    3.) In c2 you can control when a platform object gets updated by calling the action you just created. Use enable/disable solids on objects with the solid behavior to control which ones the platform object interacts with.

    4.) Use families and collision ids to update platform objects and enable/disable solids in groups and batches for the best performance, project scalablity, and pretty code.

    5.) Yay. Or perhaps not. If the ladder then give holler. Usually I holler back. If the former feel free to add me to the credits of your autobiography when you are famous. I'm sure I'm the reason why.

  • Try Construct 3

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

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

    I was curious how often c2 users purchase assets. A few years ago, it seems the c2 community was happy to share effects, behaviors, etc for free. I'm trying to gauge the worthwhile-ness of putting something on the asset store instead of simply sharing it. If nobody buys it, it sort of makes the knowledge useless right?

  • jomo has a good point. I also add global sprites and use them as variable containers. The downside is you must make sure these objects exist on every layout or create them at the start of layouts you will need them on. I have an object called Global and then a bunch of instance variables on it. When I want a variable I simply say Global.whatever. Makes it easy for me.

  • Solomon - I'm sending you a pm, I didn't want to hijack the thread too much!

  • Cyberphaze - It shouldn't really matter to the cpu if it is a shader that does the work.

Ruskul's avatar

Ruskul

Member since 23 Nov, 2013

Twitter
Ruskul has 2 followers

Trophy Case

  • 11-Year Club
  • Forum Contributor Made 100 posts in the forums
  • Forum Patron Made 500 posts in the forums
  • x6
    Coach One of your tutorials has over 1,000 readers
  • Educator One of your tutorials has over 10,000 readers
  • Regular Visitor Visited Construct.net 7 days in a row
  • RTFM Read the fabulous manual
  • Email Verified

Progress

18/44
How to earn trophies