SoupOrWorm's Forum Posts

  • Here is the file if its an issue with the events or project structure or smth. dropbox.com/scl/fi/vo2upm80wnszgkgad2iik/mousebuttontest.c3p

  • Have you tried this?

    runtime.globalVars.varName = button;

    Thanks for the response. I just tried this, but it doesn't seem to be working looking at the devtools. Any idea why?

    // Import any other script files here, e.g.:
    // import * as myModule from "./mymodule.js";
    
    runOnStartup(async runtime =>
    {
    	// Code to run on the loading screen.
    	// Note layouts, objects etc. are not yet available.
    	
    	runtime.addEventListener("beforeprojectstart", () => OnBeforeProjectStart(runtime));
    });
    
    async function OnBeforeProjectStart(runtime)
    {
    	// Code to run just before 'On start of layout' on
    	// the first layout. Loading has finished and initial
    	// instances are created and available to use here.
    	document.addEventListener("mousedown", (e) => {e.preventDefault(); mousedown(e.clientX, e.clientY, e.button)});
    	
    	
    	runtime.addEventListener("tick", () => Tick(runtime));
    }
    
    function mousedown(x, y, button){
    	console.log(button);
    	runtime.globalVars.mouseButtonNum = button;
    }
    
    function Tick(runtime)
    {
    	
    }
    
  • Bear with me, because I am very new to JS.

    Here is my code for getting the mouse button (including forward and backward) in JS:

    // Import any other script files here, e.g.:
    // import * as myModule from "./mymodule.js";
    
    runOnStartup(async runtime =>
    {
    	// Code to run on the loading screen.
    	// Note layouts, objects etc. are not yet available.
    	
    	runtime.addEventListener("beforeprojectstart", () => OnBeforeProjectStart(runtime));
    });
    
    async function OnBeforeProjectStart(runtime)
    {
    	// Code to run just before 'On start of layout' on
    	// the first layout. Loading has finished and initial
    	// instances are created and available to use here.
    	document.addEventListener("mousedown", (e) => {e.preventDefault(); mousedown(e.clientX, e.clientY, e.button)});
    	
    	
    	runtime.addEventListener("tick", () => Tick(runtime));
    }
    
    function mousedown(x, y, button){
    console.log(button);
    }
    
    function Tick(runtime)
    {
    	// Code to run every tick
    }
    

    Simply put, I want to use the 'button' number variable in an event sheet, with as little extra code useage as possible. Any ideas?

  • > I use the current layer numbers to spawn objects in event sheets, so they will be on the wrong layer if I dont manually change all of them

    That's why you should always name your layers properly and use layer names (not numbers) in all events.

    Oh, I didn't know I can just use the names. Well that should make things easier in the future.

  • The only way to do this is to move it to another layer.

    The only reason why I am not just doing that is because I want to put an object on the very bottom layer, but if I make a new layer on the bottom it pushes all of the layer numbers up one. that's an issue because I use the current layer numbers to spawn objects in event sheets, so they will be on the wrong layer if I dont manually change all of them

    Is there any other workaround to this (such as manually changing the layer numbers), or do I have to manually change all of the numbers in the event sheets?

  • This is pretty self explainitory. I want a sprite to not be affected by the effect of it's layer.

  • Oh wait i said 'mouse' instead of 'mousedown'. My bad. It works great!

  • It took me all night to figure out, now I know Js :p

    I've tried uh, borrowing your code and I keep getting this error:

    Uncaught ReferenceError: mouse is not defined at HTMLDocument.<anonymous> (main.js:17:69)

    This is the code:

    // Import any other script files here, e.g.:
    // import * as myModule from "./mymodule.js";
    
    runOnStartup(async runtime =>
    {
    	// Code to run on the loading screen.
    	// Note layouts, objects etc. are not yet available.
    	
    	runtime.addEventListener("beforeprojectstart", () => OnBeforeProjectStart(runtime));
    });
    
    async function OnBeforeProjectStart(runtime)
    {
    	// Code to run just before 'On start of layout' on
    	// the first layout. Loading has finished and initial
    	// instances are created and available to use here.
    	document.addEventListener("mousedown", (e) => {e.preventDefault(); mouse(e.clientX, e.clientY, e.button)});
    	
    	
    	runtime.addEventListener("tick", () => Tick(runtime));
    }
    
    function mousedown(x, y, button){
    console.log(button);
    }
    
    function Tick(runtime)
    {
    	// Code to run every tick
    }
    
    
    

    Do you know what this is about?

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Maybe you could do the parallax manually. Just need two instance variables: startx and rate. Then you could do something like this:

    Start of layout
    — sprite: set startX to self.x-scrollx*self.rate
    
    Every tick
    — sprite: set x to self.startx+scrollx*self.rate

    Maybe tweak the start offset as needed.

    This is perfect, thank you!

  • I know that this has been asked before, but I need to set the paralax for multiple individual objects, and I can't just add more layers because that would mess up a bunch of stuff in my event sheets.

    If anyone has an idea of how to set the paralax of an object, either through events or otherwise, please let me know.

    Tagged:

  • Unfortunately the side buttons are detected as browser back and browser forward not as inputs.

    Intresting. If they are detected as forward and backward, does that mean that they may be able to be used in conditions still?

  • Hey, I'm tryna add keybinds to my game and I think I have the keyboard (and most likely mouse/gamepad) side of things figured out, but I am wondering if I can bind things to the buttons on the side of my mouse. I know that they obviously arent the same between mouses (mice?), but I have seen other games do it so I just want to know if it's possable in C3.

    Tagged:

  • I just made a seprate prototype. I t seems to be working a bit better, but it skips over some clips for some reason when playing back. dropbox.com/scl/fi/5aqfz7whw5pxq11h3l88h/videotest.c3p

  • This works fine for me?

    Can you send me that project file? I don't know why it isnt working for me.

  • Yeah, I think I have everything figured out but how to play a video in-game from VideoRecorder.RecordingURL without downloading it. Is this possible?