Grimmy's Forum Posts

  • Cancel that I found it. I use..

    -> DrawingCanvas: Paste object UserMedia without effects

    at the instant I take a photo and it works..

    I have no idea why UserMedia takes 3 seconds to do exactly the same thing. I'll just use this instead.

  • Hmm, any idea how I do that? I cant see any relevant actions.

    I tried Save snapshot then On Snapshot>Load Snapshot to canvas but it doesn't seem to do anything?

  • I want to take a snapshot and show a preview of the shot taken. However, on device it takes a few seconds for the snapshot to be ready after taking the shot.(On PC this works instantaneously)

    So, In the meantime I would like to 'freeze' the camera view in the same frame otherwise it becomes confusing when you take a snapshot and the result of the shot it spits out is something that doesn't correlate to the current display of the camera. Is it possible?

    Note: if there is a way to speed up the time it takes between UserMedia.SnapshotURL. TakeSnapshot and OnSnapShotReady that would be preferable (Currently it's at about 3 seconds on quite a high end android)

    Thanks

  • I have exactly the same issue. It seems like a very long delay (3-4 seconds). Setting the JPEG quality to 0 has no affect on the speed either.

    Did you find an answer?

  • I understand but there are a some points to consider:

    -Even when I do my Network stuff on Android the connection always reports success regardless of whether it fails or not.

    -There is a disparity between the PC version and the Android version.

    For example: the following works fine on PC but reports always connected on Android with all wifi/mobile data disconeccted..why?

    var xmlHttp = new XMLHttpRequest();
    	
    	//alert("Csxsxs");
    	xmlHttp.open( "GET", "https://www.pigobo.com", true );
    	xmlHttp.setRequestHeader("Access-Control-Allow-Origin", "*");
    	xmlHttp.send();
    	
    	
    	xmlHttp.onreadystatechange = function(e) {
    	
    		if (xmlHttp.readyState != 4) {
    			runtime.callFunction("Change_Connection_Status",0);
    		 return;
    		}
    
    		if (xmlHttp.status == 200) {
    			runtime.callFunction("Change_Connection_Status",1);
    		}
    		else
    		{
    			runtime.callFunction("Change_Connection_Status",0);
    		}
    	}
    

    TBH what consists of online or not is really a design choice I should be making but the issue is that when this kind of thing is happening I am unable to carry it out consistently on different devices (PC or mobile); which is probably the real issue.

    That said, if this question can be answered then I'm a happy..

    Is there a consistent way I can check if my app can connect to a specific website (on a mobile device) and return success/fail?

    Cheers

  • I tried that too but it didn't work either. From what I remember it always returned the same on device.

    I think it was already reported as a bug but I don't think it was addressed There is a report here: github.com/Scirra/Construct-3-bugs/issues/3087

  • As an exported debug apk on device it doesn't seem to work. Does it work for you like that?

  • Yes, that only works on PC. It doesn't do anything on mobile. God knows why not. :(

  • Still no luck. I even tried doing this script which works perfectly fine on PC but on device it always returns as connected..

    function NetworkTest(runtime)
    {
    	var xmlHttp = new XMLHttpRequest();
    	xmlHttp.open( "GET", "https://www.mysite.com", true );
    	xmlHttp.setRequestHeader("Access-Control-Allow-Origin", "*");
    	xmlHttp.send();
    	
    
    	xmlHttp.onerror =function ()
    	{
    		runtime.callFunction("Change_Connection_Status",0);//NOT CONNECTED
    	}
    	
    	xmlHttp.onload =function ()
    	{
    		
    		runtime.callFunction("Change_Connection_Status",1);//CONNECTED
    	}
    	
    }
    
  • It seems like an on completed Ajax event gets run even when there is no internet connection. Is that right?

    I'm trying to make a reliable way to detect internet connection on device and I would have thought the Ajax On Completed request wouldn't trigger without a connection but apparently not.

    I am currently at a loss of how to detect internet connection on device. I've spent 2 days on this so far.!?!?

    Anyone know the answer? Thanks

  • I cant share the capx but the events to do with the predict function script above look like this:

    [PREDICT]

    | Local number Variable1‎ = 0

    ----* On function 'Do_Sensight_Request'

    ----* Parameter 'image' (String)

    -----> Functions: Call Hide Results

    -----> Functions: Call Reposition Last Photo

    -----> System: Wait for previous actions to complete

    -----> System: Set isDoingPrediction to 1

    -----> LastPhoto: Load image from UserMedia.SnapshotURL (Keep current size, cross-origin anonymous)

    -----> Functions: Call AnimateSnapshot

    -----> Run JavaScript:

    file_in= await runtime.assets.fetchBlob(localVars.image);

    predict(runtime);

    // we got the data now top the loader and update

    ----* On function 'Event_Got_Data'

    -----> Run JavaScript: GetResult(runtime);

    -----> JSON: Parse JSON string returned_data

    -----> System: Set isDoingPrediction to 0

    -----> Functions: Call Update Results

    ----* On function 'Update Results'

    -----> System: Set layer "Results" Visible

    -----> System: Set layer "Loader" Invisible

    -----> ResultText_1: Set text to JSON.Get("0.label")&" : "&JSON.Get("0.score")&"%"

    -----> ResultText_2: Set text to JSON.Get("1.label")&" : "&JSON.Get("1.score")&"%"

    -----> ResultText_3: Set text to JSON.Get("2.label")&" : "&JSON.Get("2.score")&"%"

    ----* On function 'Hide Results'

    -----> System: Set layer "Loader" Visible

    -----> System: Set layer "Results" Invisible

    Hopefully that should be enough to get you through..

  • None of these methods are working for me on device. I have 'always connected' regardless if I am actually connected or not and I'm doing an AJAX check to

    "https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"

    every 2 seconds. (I tried various other websites too)

    Like everyone said the browser event doesn't work on a device and nor does the PlatformInfo.ConnectionRTT method work (always returns 0 on device).

    Regarding CORS if I add a header "Access-Control-Allow-Origin" "*" then I just get Not COnnected all the time.

    I also tried various plugins of which all had other compatibility issues.

    I would have thought this was a very commonly used feature in most mobile games, so I'm surprised there isn't an obvious solution.

    Where to turn next?

  • SOLVED

    Even if nobody replies, I think that just the act of posting a question here seems to bring about some kind of mystical epiphany.:)

    In case anyone should ever need this; to change this to an asynchronous function which runs while your game is still running, it should be something like this:

    function apiPostRequest(request, body,runtime) {
    	var xmlHttp = new XMLHttpRequest();
    	
    	xmlHttp.open( "POST", baseApiURL + request, true );//TRUE indicates asynchronous
    	xmlHttp.setRequestHeader('Content-Type', 'application/octet-stream');
    	xmlHttp.setRequestHeader('X-Auth-token', token);
    	
    	xmlHttp.onload =function (e)
    	{
    		
    		console.log("Resp: "+xmlHttp.responseText);
    		//alert ("Resp :"+xmlHttp.responseText);
    
    		resp=xmlHttp.responseText;
    		results=JSON.parse(xmlHttp.responseText);
    		
    		runtime.globalVars.returned_data = xmlHttp.responseText;
    		runtime.callFunction("Event_Got_Data");//call event sheet function once complete
    
    	}
    
    	xmlHttp.send(body);
    	
    }
    
  • I'm currently doing a XMLHttpRequest which works fine but holds up the rest of the game until the data is returned.

    How would I keep the game running while the request is going on in the background?

    Current request looks like this:

    function apiPostRequest(request, body) {
    	var xmlHttp = new XMLHttpRequest();
    	xmlHttp.open( "POST", baseApiURL + request, false );
    	xmlHttp.setRequestHeader('Content-Type', 'application/octet-stream');
    	xmlHttp.setRequestHeader('X-Auth-token', token);
    	xmlHttp.send(body);
    	console.log("Resp: "+xmlHttp.responseText);
    	
    	resp=xmlHttp.responseText;
    	
    	return xmlHttp.responseText;
    }
    
  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • You do not have permission to view this post