tobyteh's Forum Posts

  • Hi,

    I am working on an in game CMD. I want to implement autocomplete for commands, however, pressing tab shifts the focus from the game to my different tabs in chrome.

    Is it possible to use the preventDefault() method in C3?

    Like:

    	input.keydown(function(event){
     		if (event.keyCode === 9) {
    		 event.preventDefault();
    		}
    	});
    

    Since the isKeyDown(keyStringOrWhich) does not provide an event but only a boolean.

    Thanks in advance,

    Toby

  • Hi Ashley,

    thanks for getting back to me so quickly! You're right, I should have provided more information.

    I am trying myself at an ingame terminal and started with a rough implementation:

    function Terminal(runtime) {
     this.commandList;
     this.terminalInput = runtime.objects.tTerminalInput.getFirstInstance();
     this.terminalText = runtime.objects.tTerminalText.getFirstInstance();
     this.selectedObject;
     this.typeTime = 0.5;
    }
    
    Terminal.prototype.openTerminal = function (runtime, object) {
    	// save the selected object
    	this.selectedObject = object[0];
    	// save the available commands of the selected object
    	this.commandList = this.selectedObject.instVars.commandList.split(',');
    	this.terminalText.typewriterText("Hacking " + this.selectedObject.objectType.name, this.typeTime);
    	// show terminal UI
    	runtime.layout.getLayer("Terminal").isVisible = 1;
     	player.behaviors.Platform.isEnabled = 0;
    	player.instVars.terminalIsOpen = 1;
    	
    	
    };
    
    Terminal.prototype.closeTerminal = function (runtime) {
    	// hide terminal UI
    	runtime.layout.getLayer("Terminal").isVisible = 0;
     	player.behaviors.Platform.isEnabled = 1;
    	player.instVars.terminalIsOpen = 0;
    	
    };
    
    // get the cmd input of the player
    Terminal.prototype.getTextInput = function(runtime){
    	terminal.runCommanIfExists(this.terminalInput.text, runtime);
    	console.log("input: " + this.terminalInput.text);
    	this.terminalInput.text = "";
    }
    
    // check if entered command exists for the selected object
    Terminal.prototype.runCommanIfExists = function(input, runtime){
    	this.commandList.forEach(function(command) {
    		if(command == input){
    			terminal.runFunction(input, runtime);
    		};
    	}); 
    }
    
    Terminal.prototype.runFunction = function(command, runtime){
    	console.log("command: " + command);
    	switch (command) {
    		case "help":
    			this.fHelp();
    			break;	
    		case "exit":
    			this.fExit(runtime);
    			break;
    	 	case "exit -h":
    			this.fExitH();
    			break;
    	 	case "sleep":
    			this.fSleep();
    			break;	
    	 	default:
    	 	console.log("default");
    			//this.fUnknownCommand();
    	}
    }
    
    //
    //	TERMINAL FUNCTIONS
    //
    
    Terminal.prototype.fHelp = function(){
    	var string = "This object supports the following functions. Enter <command> -h to get more information.";
    	this.commandList.forEach(function(command) {
    		string += "\n- " + command;
    	});
    	this.terminalText.typewriterText(string, this.typeTime);
    }
    
    Terminal.prototype.fExit = function(runtime){
    	this.closeTerminal(runtime);
    }
    
    Terminal.prototype.fExitH = function(){
    	this.terminalText.typewriterText("exit - close the terminal", this.typeTime);
    }
    
    Terminal.prototype.fUnknownCommand = function(){
    	this.terminalText.typewriterText("Not a valid command, try help.", this.typeTime);
    }
    
    Terminal.prototype.fSleep = function(){
    	console.log("sleeping nowwww");
    }
    

    The player can enter commands in a text input field and when they hit enter their command is parsed.

    While writing this text I am realizing that only commands provided by the selected object will work. And my test object does not provide other commands than help and exit in its commandList.

    Wow.. so much for code blindness. But writing this post helped me find it, so thank you very much! Especially for the fast response. I will mark this as solved.

  • Hey everyone,

    I have the following piece of code

    Terminal.prototype.runFunction = function(command, runtime){
    	switch (command) {
    	 case "help":
    		this.fHelp();
    		break;	
    	 case "exit":
    		this.fExit(runtime);
    		break;	
    	 default:
    	 console.log("default");
    	 this.fUnknownCommand();
    	}
    }
    

    The switch statement works for the cases help and exit. However, if I handover a string that is not in one of the cases the default case will not run.

    I tested the code in the browser console and was able to run the default state.

    Is this a problem of C3?

    Cheers,

    Toby

    EDIT:

    Adding more cases show's that it is not a default case problem.

    	switch (command) {
    	 case "help":
    		this.fHelp();
    		break;	
    	 case "exit":
    		this.fExit(runtime);
    		break;
    	 case "exit -h":
    		this.fExitH();
    		break;
    	 case "sleep":
    		this.fSleep();
    		break;	
    	 default:
    	 	console.log("default");
    		//this.fUnknownCommand();
    }
    

    Every case after "exit" will not run.

    Tagged:

  • You do not have permission to view this post

  • Yes, thank you I completely forgot about that.

    Yet, the problem with the restarting audio still persisted. I didn't mention that my prototype is an audio-only game. Since the player won't see the objects anyway, I ended up rotating the whole world around the player, this way the audio doesn't restart.

    This might not be a solution if you are working with visuals, though.

  • Hey folks,

    I am working on a top down game with positional audio.

    Let's say the player (the listener object) is facing north and a sound emitting object is left of it. The player then rotates 90 degrees clockwise so logically the sound would be behind the player, from their listening perspective. Any idea if that is possible with construct?

    So far nothing happens when I rotate the player.

    Cheers,

    Toby

  • Does exactly what it says

    Only wish for improvement: be able to set the volume

    Cheers,

    Toby

  • Hi everyone,

    I am working on a small prototype that sends log information to a nodeJS server via the websocket protocol. Everything works fine in preview, however, if I export my prototype and built it for Android via Phonegap, the apk cannot connect to my server.

    I did not find any network specific permissions when exporting in Construct.

    I really hope someone has an idea.

    Cheers,

    Toby

    EDIT: Little update from my side. I checked for websocket support both in chrome under Android and my exported APK and both return true. So the support itself seems to be there, however, nothing is sent to my server. Trying the same thing on chrome for Mac/Windows does sent information to my server.

    EDIT2: I solved it. Android is requiring a secure websocket connection. It will not connect to a non-secure websocket. Hope this will help someone.

  • Hi,

    I'm working on a prototype with TTS. Running it inChrome gives me a wide selection of TTS voices. However, NWJS builds just leave me with the default system one.

    This is a problem if the system running the game does not have English as it's main language, as TTS text sounds very funny and unusable.

    Is it possible to access more voices with NWJS exports?

    Thanks,

    spinz89

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • I second that!

  • You got a point there. But unfortunately I'm not allowed to publish the capx.

    I'm afraid that one can't change anything about it anyway..

    The more objects that have to be loaded, when changing a layout, the longer the engine freezes. I guess it's just how it is.

  • Push

  • try this tutorial

    https://www.scirra.com/tutorials/533/fo ... ing-screen

    Yes I considered that. But there are a few limitations with the loader layout, as mentioned in the tutorials.

    "Loader layouts are not shown when publishing as native apps on mobile..."

    " Loader layouts are only ever shown the very first time the game is being downloaded from the web..."

    (source: https://www.scirra.com/tutorials/318/ho ... ng-screens)

    Also: When switching to a layout that has quiet a lot to load, the engine freezes completely.

  • I have the same problem: But I also want to get rid of the freezing.

    My short-term solution is the following:

    If you click the play button (which directs you to a new layout), I display a loading image, then wait for 0.5sec (so the image has a chance to be displayed) and then call the 'go to layout' function.

    Since the game is actually freezing the loading image can't be animated. But at least the player has some kind of feedback.

  • Hi,

    I hope this wasn't posted before. Google didn't find me anything useful, at least.

    My problem is that construct freezes for a couple of seconds when I am clicking the play button in my main menu and then change to the first level of the game. (I'm using 'go to layout')

    The level consists out of ca. 55 objects (sprites, tiled backgrounds, texts), some of the sprites have animations. I'm running r190.

    Is there any way to remove that freeze? I tried putting every object into my main menu layout, hoping that construct would then cache them and the 'go to layout' wouldn't freeze any more. But no luck so far.

    I also tried to show a spinning cirlce, but since the game is really freezing, the circle also freezes. :/

    Any ideas on that?

    Is there something like 'switch to layout when layout is loaded'?

    Cheers,

    spinz89