Sami424's Recent Forum Activity

  • hello everyone !

    how u doing ?

    Is it possible to hide or show a layer from a specific layout or from the current layout?

    You can get specific layers easily from a layout:

    // get a layer from the current layout
    let myLayer = runtime.layout.getLayer(1) // 1 is the index of my layer, you can also just put the name of the layer as parameter.
    

    after getting the layer you can set visibility:

    myLayer.isVisible = false;// Will hide the layer

    You can also use the

    runtime.getLayout("myLayout");
    

    to get a specific layout.

  • I've been trying to create a system for reading and writing variables through expressions (i.e. a function to evaluate an expression like "Var1 == 0 & Var2 = 1" and similar functions to change/add/subtract variables). For a while, I've been assuming the best way to do this is to declare the variables in the Event Sheet as normal, then interact with them through code but it occurred to me after another readthrough of the (brilliant) scripting documentation that I could just declare the variables in script (let Var1 = 1, etc.) and avoid the awkwardness of Event Sheet/Javascript cross-communication altogether.

    I'm still not completely confident with Javascript and would still keep the majority of the project in visual code. With that in mind, are there any particular pitfalls or dangers to handling most of my variables in javascript?

    As Ashley mentioned it depends on what your doing, i actually like working with the variables in the event sheet.

    Declaring a variable like

    Let myVar = 5; 

    is just declaring the property in JavaScript .

    Is not the same as declaring s global,local or instance variable ( i think )

  • Hi Ashley

    Thank you for your reply.

    Ok for arguments sake I have created a new project and on the event sheet I've added one script as follows

    System > On start of layout >

    let audio = new Audio("https://streaming.galaxywebsolutions.com/stream/moorland");

    audio.play();

    When you run the project it starts and plays the audio from the script.

    However as it is ran direct from the script I can not tick the play in background on the audio object as the audio object as not been added to the project, therefore all works perfectly apart from the background issue when the app sleeps or loses focus.

    I can not call (or at least I don't know how to call) the stream from the audio object as it is continuous and a live mpeg stream which can not be changed to a different format.

    How would I get my project to steam this URL via the audio object so that I can then check the play in background box, so that the stream continues to play in background mode on both Android & iPhone?

    Many thanks

    Adrian

    I dont think you can make it play in the background on mobile phones using the default audio object. The option is for browsers that support it.

    I might be wrong tho.

  • Edit: so importing and exporting functions is working for me.

    How do i import a class for example a sub class that i made ? Do i have to instantiate the class before using it like

    Let myClass = new myClass():
  • Im not sure what i am doing wrong,

    Lets say i create a class :

    class myClass
    {
    Let x = 5;
    
    alertUser()
    { 
    alert('works');
    }
    } 

    Now in main.js i need to import this class right ?

    import * as myClass from ("./myClass.js");
    
     

    Even if i add export to the class, this still gives me undefined class error, what am i doing wrong? I know programming i am just stuck on the import/export part.

    I am trying this in the main.js file so i am not trying to run scripts from event sheet.

  • Chadori is still on it i see 🤣 great job, been using your plugins for years now..

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Here is main.js:

    let myNumber = 5;
    
    export function getMyNumber(){
    return myNumber;
    }

    here is importsForEvents.js

    import { getMyNumber } from "./main.js";
    

    Purpose of the imports file is set to import for events.

    Why is getMyNumber() still undefined when ran on start of layout in event sheet as script?

  • Can I make Money to Publish game on free Online Arcade in Construct 3 Own Platform.

    How to monetize ads?

    https://www.construct.net/en/free-online-games/ninja-samurai-runner-online-37157

    Dont think you can add ads to the scirra arcade, but you can add it to your own HTML exports, and mobile exports using Admobs plugin.

  • Hi, I am getting a black screen, when I hit preview button. Why ?

    I am using Firebase BASIC Pack (12.0.2). I need a solution for this, please.

    When i delete the Firebase BASIC Pack (12.0.2), it works fine.

    So why is this happening.

    Are you on chromebook? Also try using chrome, better than firefox.

  • You do not have permission to view this post

  • Yeah but the IronSource Addon from this guy is 160$, only worth it if my game becomes a great success. If you earn „only“ a couple hundred bucks per month from advertising mediation does not really get you higher ecpm, because other networks often value customers with larger audiences. At least thats what I‘ve heard.

    It is true, but you also get alot of other plugins from Chadori, which are amazing.

    But you can also try to make your own plugin using instructions from ironsource documentation.

    But i get your point, i am not sure if there is a cheaper addon out there.

Sami424's avatar

Sami424

Online Now

Member since 9 Jul, 2018
Last online 18 Jan, 2025

Twitter
Sami424 has 5 followers

Trophy Case

  • 6-Year Club
  • Entrepreneur Sold something in the asset store
  • Forum Contributor Made 100 posts in the forums
  • Regular Visitor Visited Construct.net 7 days in a row
  • RTFM Read the fabulous manual
  • Email Verified

Progress

11/44
How to earn trophies