Haematite's Forum Posts

  • > chunchun, hmm that's weird. You should only need to regenerate the definitions if you add new objects etc. in Construct. That looks like it might be a VSCode bug as that bit's not handled by the extension at that point

    Hello, I have the same problem on two different computers! Is there a way around this? -Use “Type”a lot. can only be “Redefined”frequently, but each 'redefinition' has to wait 30 seconds or so.~~~If there’s anything I can do, anything I missed, please contact me

    chunchun I've just been looking at this and I think VSCode isn't picking up the definition file. If you add a file called jsconfig.json into the project (in the same folder as the c3.d.ts) with the following contents:

    { }

    It should work better.

  • Felixoo no idea why, that looks like it should be working. I've recreated pretty much exactly what you've done here and it's working fine, if you want to take a look:

    edwardbonnett.com/script-test.c3p

  • So if you only have one ground object and one player object you should just be able to do this:

    	const player = runtime.objects.Player.getFirstInstance();
    	const ground = runtime.objects.Ground.getFirstInstance();
    	
    	if (player.testOverlap(ground)) {
    		console.log('Hit');
    	}
    

    If you have many ground objects and one player object you can do this:

    	const player = runtime.objects.Player.getFirstInstance();
    	const groundObjects = runtime.objects.Ground.getAllInstances();
    	// loop through every ground object and see if any of them overlap with the player
    	groundObjects.forEach((ground) => {
    		if (player.testOverlap(ground)) {
    			console.log('Hit');
    		}
    	});
    	
    

    And if you have many ground objects and many player objects you'd need to something like this:

    	const playerObjects = runtime.objects.Player.getAllInstances();
    	const groundObjects = runtime.objects.Ground.getAllInstances();
    	// loop through every player object and every ground object and see if any of them overlap with the player
    	playerObjects.forEach((player) => {
    		groundObjects.forEach((ground) => {
    			if (player.testOverlap(ground)) {
    				console.log('Hit');
    			}
    		});
    	});
    

    Hopefully that makes sense! Basically "getAllInstances" returns an array, or list, of your objects and you need to loop through each of them and test if they overlap with your player individually. "getFirstInstance" just returns one of the objects, the first one in that list - which is fine if you only have one of that particular object(such as a player object)

  • chunchun, hmm that's weird. You should only need to regenerate the definitions if you add new objects etc. in Construct. That looks like it might be a VSCode bug as that bit's not handled by the extension at that point

  • Great! Let me know if you encounter any other issues or think of any improvement!

  • chunchunPinbak Think I've just managed to sort this. I was assuming that the eventSheets and families folders existed and it was failing. If you update to the newest version of the vscode extension then it's hopefully fixed. Let me know if you're still having issues! Thanks both for testing this

    It should auto update to v1.0.6:

    But I think you can do it manually too marketplace.visualstudio.com/items

  • Pinbak How strange, so there's no c3.d.ts file in the root of your project?

    Are you able to take a look in the "Log (Extension Host)" output in vscode and see if there's any errors coming up when you're generating?

    I've just retried on a few projects and it seems to be generating ok for me so I'm thinking it must be a certain object / instance variable name it's struggling with. If you're ok with sharing, a list of your object names might be useful too - in case it is that.

    Really appreciate your help on this!

  • Pinbak In order to connect to Construct you'll need to make sure you add the vscode addon to your project: construct.net/en/make-games/addons/603/vs-code-plugin

    If you just want the code autocomplete you can just ignore the code message though.

    The addon was broken (thanks to chunchun for pointing that out!) so you may need to update it to the new version. Let me know if you're still having issues though

  • Hi all, I have created a Visual Studio Code extension which can be downloaded here:

    marketplace.visualstudio.com/items

    This features auto-completion for javascript projects, as well as generating typescript definitions based on your project (so you'll get behaviors, instance variables, global variables etc. all available). This includes typescript definitions for all currently exposed scripting interfaces and I'll try and keep these up to date.

    If you install the VS Code Plugin from the addon store and add it to your construct project you can also set up easier remote debugging and auto script reloading:

    construct.net/en/make-games/addons/603/vs-code-plugin

    If anyone just wants the basic typescript definitions without your own objects etc. in it then they're available here, you might need to update the behaviors of the IWorldInstance as I currrently only inject the relevant ones to new interfaces as required as part of the extension:

    github.com/EdwardBonnett/c3-vscode-extension/blob/main/templates/c3.d.ts

    There's a lot more details on the extension page, but I've never created a VS Code extension before and I'd love any feedback / suggestions for improvements.

    Thanks!

    Tagged:

  • I've been getting annoyed with having to keep refreshing the scripts when working in an external IDE so I've made a plugin to take care of that for me. It will check every couple of seconds whether any files have changed and then re-add them to the solution if they have.

    construct.net/en/make-games/addons/600/automatic-script-reloading

    This makes use of getting the folder handler straight from the IndexedDB storage which I'm guessing isn't intended - so this may well break in the future. There's also a small possibility of file corruption; I've not encountered any issues yet, but use at your own risk and take a backup first.

    Tagged:

  • I thought that might be your answer, but thought it was worth asking the question anyway. Thanks!

  • Not sure if this is the right place to put this, but I'm curious as to whether there will ever be a move over from the CodeMirror library currently powering the script editor to the one behind VS Code, Monaco (https://microsoft.github.io/monaco-editor/).

    I find the general syntax highlighting, search, line wrapping, code completion, lack of keyboard shortcuts etc. to be quite frustrating to use in the current editor and would love to see a slightly more fleshed out one.

    I'm currently using Construct to create a game entirely with js and in comparison to other editors I use in my day job I find it very frustrating to use.

    Alternatively, some way to be able to hook into some more features with the plugins sdk so I can do this myself would be great. I'm more than happy to implement it, and have actually done this in other projects in the past.

    I'm aware that we can use external code editors when using it as a pwa, but it seems a shame to have to resort to that when this is primarily a browser based tool.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Thanks, it's pretty well suited for mobile =)

  • Finally managed to port my puzzle game across to Android!

    <img src="http://www.jargogle.co.uk/games/fred/SS1.jpg" border="0">

    <img src="http://www.jargogle.co.uk/games/fred/SS2.jpg" border="0">

    <img src="http://www.jargogle.co.uk/games/fred/SS3.jpg" border="0">

    In the game you plan your path by placing blocks in a near-infinite combination and then watch as Fred follows the route you set out for him.

    You can check it out here:

    https://play.google.com/store/apps/details?id=com.Jargogle.Fred

    There's also a trailer here:

    Subscribe to Construct videos now

    Please check it out and let me know what you think =)

  • I had this problem in a game I made a while back. This was my solution.

    Player is standing on platform * Set platform jump strength to 100

    Block opacity < 100             * Simulate Jump

                                                 * Wait 0.1 Seconds

                                                 *Set platform jump strength back to original

    This meant he gave a little jump when the block vanished, but it worked pretty well. I'm just setting his jump strength to something low, making him jump, then setting the jump strength back.

    Hope this is of some help