dop2000's Recent Forum Activity

  • Mouse.x=oldX
    Mouse.y=oldY : Mouse not moving
    
    Else : Mouse is moving
    
    On every tick : Set oldX to Mouse.x, Set oldY to Mouse.Y
    
  • Then what should I use? For each?

    Depends on the task - For Each, Timer behavior, state machine. But "Trigger once" will only cause bugs when you use it like that.

  • The "Lookup Variables" idea is interesting, but setting it up must be a chore.

    Here are my tips:

    1. In all my big projects, I create a AudioPlay function and call it whenever I need to play a sound, instead of using the "Play" action directly. This makes it easy to modify the entire sound system later. For example, you can quickly implement a global volume setting or adjust how audio tags are named.

    2. Similarly, I use a single _LOG function for console logging. This allows me to disable all logs before publishing the game.

    3. Another logging tip: right-clicking anywhere prints all objects under mouse cursor to the console. This is incredibly useful in large games with thousands of objects, many of which are hidden. I used to waste a lot of time manually searching for the right instance in the debugger.

    Here is the code:

    const excludeFamilies = true;
    
    const results = []; // Collect results in an array
    
    for (const objectTypeName in runtime.objects) {
    
    	const allInstances = runtime.objects[objectTypeName].getAllInstances();
     const filteredInstances = allInstances.filter((e) => e.layer && e.layer.name);
    
    	var idx=0;
    	for(var i=0; i<filteredInstances.length; i++) {
    		const instance = filteredInstances[i];
    		const layerIndex = instance.layer.index;
     const x = runtime.objects.Mouse.getMouseX(layerIndex);
     const y = runtime.objects.Mouse.getMouseY(layerIndex);
    
    		const left = instance.getBoundingBox().left;
     const top = instance.getBoundingBox().top;
     const right = instance.getBoundingBox().right;
     const bottom = instance.getBoundingBox().bottom;
    
     // Check if the mouse cursor is within the instance's bounding box
    		// If excludeFamilies=true, duplicate UIDs will be skipped
    		if (excludeFamilies===false || !results.some(record => record.UID === instance.uid)) {
    			if (x >= left && x <= right && y >= top && y <= bottom) {
    				// console.log(`${objectTypeName}\t\tLayer: ${instance.layer.name},\t\tUID: ${instance.uid}`);
    					results.push({
    						Object: objectTypeName,
    						Layer: instance.layer.name,
    						UID: instance.uid,
    						IID: idx,
    						Visible: instance.isVisible,
    						Collisions: instance.isCollisionEnabled || "",
    						Animation: (instance.animation ? (instance.animation.name+":"+instance.animationFrame) : "")
    					});
    
    			}
    		}
    		idx++;
    
     }
    }
    
    console.table(results);

    4. My final logging tip: I created an addon (which, unfortunately, won't work with SDK2) that adds event sheet names and event numbers to all log messages. It also allows to disable logging in the entire project. I wish the Browser object had built-in settings for this.

  • Remove "Trigger once" condition. Never use it with objects that have multiple instances.

  • Here is my attempt:

    dropbox.com/scl/fi/vbfmptsy0qdcl823c9kaw/8Direction_Gamepad.c3p

    Sliding, acceleration, deceleration - all work. The speed also changes based on how far you tilt the stick.

  • You can use "Simulate control" action. It will only work for 8 directions though, as the behavior name suggests.

    Another option is to use vectors and handle acceleration/deceleration with events.

  • and when I'm in the title screen scene, my ‘LanguageIndex’ variable resets

    Is it a global variable? Global variables are not reset by themselves. There must be an event in your code that resets it.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Ashley himself says you don’t need delta time there!

    During the aiming stage and trajectory calculations, delta time is irrelevant. You only need it after firing the projectile to adjust its speed.

  • im_pro_viz An average of dt would be the same as time/tickcount.

    I agree with R0J0hound - you don't need to use dt at all in your case.

  • Other options are: dictionary, array, static local variable, an instance variable on a global object.

  • if we do the same for “round”, this method also shows itself well.

    Yes. But floor(random(0,6)) is easier to type and understand than round(random(-0.5,5.5))

  • choose(0,1,2,3,4,5) = round(random(0,5))

    igortyhon

    No, that’s not correct. The correct expression is int(random(0,6))

    choose(0,1,2,3,4,5) = int(random(0,6))

    Using round(random(0,5)) skews the distribution — both the lowest and highest numbers in the range will have a 50% lower chance of appearing compared to the others.

    See this demo:

    dropbox.com/scl/fi/kpnbq43gc6786r9blg7xn/RandomDemo.capx

dop2000's avatar

dop2000

Member since 26 May, 2016

Twitter
dop2000 has 279 followers

Connect with dop2000

Trophy Case

  • 10-Year Club
  • Entrepreneur Sold something in the asset store
  • Jupiter Mission Supports Gordon's mission to Jupiter
  • Forum Contributor Made 100 posts in the forums
  • Forum Patron Made 500 posts in the forums
  • Forum Hero Made 1,000 posts in the forums
  • Forum Wizard Made 5,000 posts in the forums
  • Forum Unicorn Made 10,000 posts in the forums
  • x5
    Popular Game One of your games has over 1,000 players
  • x2
    Coach One of your tutorials has over 1,000 readers
  • Educator One of your tutorials has over 10,000 readers
  • Regular Visitor Visited Construct.net 7 days in a row
  • Steady Visitor Visited Construct.net 30 days in a row
  • Enduring Visitor Visited Construct.net 90 days in a row
  • Unrelenting Visitor Visited Construct.net 180 days in a row
  • Continuous Visitor Visited Construct.net 365 days in a row
  • RTFM Read the fabulous manual
  • x3
    Quick Draw First 5 people to up-vote a new Construct 3 release
  • x14
    Great Comment One of your comments gets 3 upvotes
  • Delicious Comment One of your comments gets 10 upvotes
  • Email Verified

Progress

30/44
How to earn trophies