dop2000's Forum Posts

  • If you need to make the screen white for a fraction of a second, you can add a non-transparent layer above all other layers. Set it invisible by default. When player dies, set layer visible, wait 0.1s, set layer invisible.

  • That should work. Please show your event sheet.

  • I don't know how to turn the torch off. Try the same code but with {torch: false} at the end.

  • I tried this script in "On button pressed" and it works on mobile.

    //Test browser support
    const SUPPORTS_MEDIA_DEVICES = 'mediaDevices' in navigator;
    
    if (SUPPORTS_MEDIA_DEVICES) {
     //Get the environment camera (usually the second one)
     navigator.mediaDevices.enumerateDevices().then(devices => {
    
     const cameras = devices.filter((device) => device.kind === 'videoinput');
    
     if (cameras.length === 0) {
     throw 'No camera found on this device.';
     }
     const camera = cameras[cameras.length - 1];
    
     // Create stream and get video track
     navigator.mediaDevices.getUserMedia({
     video: {
     deviceId: camera.deviceId,
     facingMode: ['user', 'environment'],
     height: {ideal: 1080},
     width: {ideal: 1920}
     }
     }).then(stream => {
     const track = stream.getVideoTracks()[0];
    
     //Create image capture object and get camera capabilities
     const imageCapture = new ImageCapture(track)
     const photoCapabilities = imageCapture.getPhotoCapabilities().then(() => {
    
     //todo: check if camera has a torch
    
     //let there be light!
     track.applyConstraints({
     advanced: [{torch: true}]
     });
     
     });
     });
     });
    
     //The light will be on as long the track exists
    
    }
    

    I guess it should work in C2 too, if you run it using Browser Execute Javascript action.

  • It doesn't matter.. Pin or add healthbar as a child to each character. You can use "Pick child" and update its width when needed.

  • If there was one elf sprite, the easiest solution would've been creating a container with the healthbar.

    With multiple sprites I suggest using the new scene graph feature.

    On Elves Created -> create a healthbar and add it as a child to the elf. When elves' health changes, pick child instance of the healthbar and update its width.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • It's difficult to style form controls, and there are many other problems with them.

    Use TiledBackground object instead, it's very easy - just change its width.

    On every tick -> Bar Set width to 300*(Player.health/100)

    where 300 is the maximum width, and 100 is the maximum health.

    Here is another example:

    howtoconstructdemos.com/simple-healthbar

  • Have you tried this script in Construct 3?

    On Button clicked event -> right click on "Add action", select "Add script" and paste that JS code.

    Or, if you are using Construct 2:

    On Button clicked event -> Browser Execute Javascript "your script here"

  • It's not executed once, it's executed as many times as specified in the loop. But if you are using a fixed value for the Wait action, all iterations will be completed after the same delay. For example:

    Repeat 10 times
    Wait 0.5s
    Add 1 to variable
    

    After 0.5 second delay all scheduled actions will happen at the same time. So the variable will be incremented by 10.

    Basically, it's equal to this:

    Wait 0.5s
    Add 1 to variable
    Add 1 to variable
    Add 1 to variable
    Add 1 to variable
    Add 1 to variable
    Add 1 to variable
    Add 1 to variable
    Add 1 to variable
    Add 1 to variable
    Add 1 to variable
    
  • You can use wain in loops, here is an example:

    For n=0 to 10
     Wait (loopindex*0.5)
     Subtract 1 from var
     Text set text to var
    
  • You can use instance or global, it's up to you.

  • You can do this in a script:

    runtime.objects["ObjName"].getFirstInstance().width

    In events the only way to do this is to add all objects into a family and pick family instance by ObjectTypeName:

    System Pick Family by evaluate Family.ObjectTypeName="ObjName"

    After that you can use Family.width

  • Use Timer behavior on the player. For example, when you cast a spell, set variable SpellEnabled=false and start a timer "cooldown". On timer event, set SpellEnabled=true

  • You mean "not equal 12"? Right-click the condition and select Invert.