thepeach's Recent Forum Activity

  • I encountered an issue when trying to minify my TypeScript project for web using "Simple" or "Advanced" mode:

    [JSC_LANGUAGE_FEATURE] This language feature is only supported for UNSTABLE mode or better: Public class fields.

    The error is from using public class fields, which are necessary for TypeScript, but also nice to have in vanilla JavaScript projects.

    Are there any recommended pipelines or solutions out there for working around this issue?

  • Here's the solution for anyone else that overlooked Ashley's article on using TypeScript in Construct:

    When using TypeScript, Construct generates a special class representing an instance for every object type and family in the project. This includes type definitions for things like the instance variables, behaviors and effects specific to that object. These classes are all in the InstanceType namespace with the name of the object.

    So, the solution was to extend DragItem from InstanceType.DragItem.

    export default class DragItem extends InstanceType.DragItem {
    	// ...
    }
    
  • How do we get behaviors on an ISpriteInstance subclass in TypeScript?

    When attempting to get the behaviors property of my subclass, I see the following error:

    Property 'behaviors' does not exist on type 'DragItem'.

    Here's my truncated code:

    main.ts

    import DragItem from './DragItem.js';
    
    runOnStartup(async runtime => {
    	runtime.objects.DragItem.setInstanceClass(DragItem);
    	// ...
    });
    

    DragItem.ts

    export default class DragItem extends ISpriteInstance {
    	constructor() {
    		super();
    		const dragDrop = this.behaviors.DragDrop; // Error
    	}
    }
    

    instanceTypes.d.ts

    (Generated)

    class __DragItemBehaviors<InstType> {
    	DragDrop: IDragDropBehaviorInstance<InstType>;
    }
    
  • Thanks for posting about this. I had a similar issue with the bullet behavior. I wanted to destroy instances after they bounced off of a solid a couple times, but testOverlapSolid() always returns false for instances where the bounceOffSolids property is true.

    I used a similar solution to what’s been discussed here (tailored to the bullet behavior), and am planning to handle instances with the platform behavior as above. I agree this isn't the smoothest implementation, especially if it needs tweaks for different behaviors. That said, it gets the job done for now.

  • Update: This workaround is no longer needed! r338 added the timeScale property and restoreTimeScale method to the scripting API.

  • ChatGPT is pretty helpful for scripting, especially for problems that aren't specific to the C3 API. The solutions usually point me in the right direction even when they're incorrect. That said, it frequently has hallucinations when writing C3 API code. I expect this will improve over time.

  • My understanding is that time scale functions are not accessible via the scripting interface in Construct. I am new to the software and unsure why that is the case. However, a workaround for this limitation is to use event sheet functions that can be called from script files. Here's an example:

    runtime.callFunction('PauseTimeScale')

  • The short answer is yes.

    Under the hood, Construct's Gamepad plugin uses the Gamepad API, which does support Switch Joy-Con controllers. You can test your connection using this demo page.

    With that said, Joy-Con controllers don't have a D-pad, and you might have mixed results with the analog stick. Construct's Gamepad plugin attempts to remap input from the Standard Gamepad layout to the Xbox 360 controller layout. Therefore, you may be better off using an Xbox 360 controller, PS4-5 controller, Nintendo Pro Controller, etc.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Ashley Thank you! That solution didn't even occur to me. I'll try it out.

  • Can anyone offer advice on using gamepads in a script-based project? I understand it's necessary to use an event sheet because the Gamepad plugin isn't accessible to the scripting interface. Here are some of my goals for the implementation:

    1. Pass Gamepad plugin data to a script file from an event sheet.
    2. Avoid introducing side effects in the event sheet.
    3. Avoid mutable global variables.

    Here's my latest attempt for the event sheet. This would be fine if I could return the data to my script file.

  • The current solution is to call an event sheet function returning the value(s) you want. Here is an example that returns the default width for a Sprite Font object named "SpriteFont":

    const width = runtime.callFunction('GetCharacterWidth');
    
  • For posterity, the suggestion can be voted on here.

thepeach's avatar

thepeach

Member since 10 Dec, 2022

None one is following thepeach yet!

Connect with thepeach