Grimmy's Recent Forum Activity

  • SOLUTION

    In order to send messages and bypass CORS issues during testing rather than use the c3_callfunction event I instead am using Window.onMesssage to send dat from the iFrame back to C3. This is how its done:

    In Child Iframe:

    //send simple message without data
    		parent.postMessage("MsgFromIframeToC3", "*");
    		
    		//send to c3 with some data
    		parent.postMessage(
    			{
    				event_id: 'MsgFromIframeToC3WithData',
    				data: {
    					v1: 'value1', 
    					v2: 'value2'
    					}
    			}, 
    			"*" 
    		); 
    

    IN C3:

    window.onmessage = function(event) {
    
    	//A single message
    	if (event.data == 'MsgFromIframeToC3') {
     console.log('Message from iFrame Received');
    		
     }
    	
    	//a message with data
     if(event.data.event_id === 'MsgFromIframeToC3WithData'){
     console.log( "c3D 3d Says: "+ JSON.stringify(event.data.data));
    		console.log(event.data.data);
    		
     }
    }
    

    ..and of course its completely possible to send message the other way (from C3 to iframe) using the same system in reverse (use window) for example (in C3):

    var myIframe = document.getElementById('myIframe');
    
    myIframe.contentWindow.postMessage('MessageToIframe', '*');
    
  • That works great. Thanks for the example! parent.c3_callFunction("myFunction")

    The problem I have now though is that my iframe isnt allowed to communicate with C3 during preview because of COrs policy.eg:

    C3_InterfaceTest.js:213 Uncaught DOMException: Blocked a frame with origin "http://localhost:8668" from accessing a cross-origin frame.

    In your example the html was part of the iframe inside C3 itself (so everything works fine) but in my case it uses an external.html file to embed.

    Although my iframe will eventually be on the same server and directory when online I have no idea how to make this work locally when testing in C3. I got a chrome extension which was supposed to block COrs but that doesnt seem to have any effect.

    Any ideas how I can test locally without having to do an upload to my website each time I need to test something?

    Cheers

  • Dead link apparently. :(

  • Primary I guess I need to somehow be able to first locate the C3 element and then somehow call a function.

    In my case the application that calls the function is actually an iframe contained within a C3 window so I thought I might use something like this...

    window.parent.c2_callFunction("FunctionFromIframe");

    But that just doesn't do anything at all.

  • I added a html page as one of the files to my project and I want to view it from the running project as an iframe.

    in the URL field of the iframe object I tried putting "/myHtmlFile.html" but nothing happens.

    if I try file://myHtmlFile.html I get an error: "Not allowed to load local resource:"

    also local/myHtmlFile.html fails with a 404 error..

    Is there a way to do this?

    ALso, I just tried uploading everything to the same folder on a server but I still get permission errors:

    Uncaught DOMException: Blocked a frame with origin "https://www.pigobo.com" from accessing a cross-origin frame.

    I cant understand because both the c3 index.html and the myHtmlFile.html are sitting in the same folder..?!?? How can this be a CORS issue?

    Cheers

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Lets say for my game I want my user to be able to choose from 1000 fonts (about 250 meg when added to the project) but obviously this is way to big for a web game.

    So, is there some way I can download the selected .ttf from a url into the project at runtime and then use it once ready?

    This way the game can launch as normal and download individual fonts as and when they are needed.

    Cheers

    Tagged:

  • Say my game is 640*480 but I want to save a huge high res screen shot of it. (1920*1080 for example). Is there any way I can do this and save it out to a file (jpeg or png for example)?

    Cheer

  • Understood, but do you have any kind of very rough idea? :) I don't want to invest too much time if its not really feasible still. I know you probably think I'm just being lazy but do you think for example it could easily do 10 bipeds on a 2 year old mobile or more like 1000...or just one. I only say this because you mentioned the problem of frame rate earlier and I'm just keen to know really if its either a huge problem or just a problem if I wanted a screen full of sprites.

    BTW..have you seen Creature Animation Pro (https://creature.kestrelmoon.com/) it looks like an amazing Spine/Spriter alternative but again I don't think there is a C3 plugin :(

  • What kind of performance are we looking at with this now? How many animals could you put in there before it slows down to below say 20fps on 'regular' pc or on mobile devices.

    I'm in a constant mental battle whether to go with something like spine or regular sprite sheets but I'm supposing regular sprite sheets eat up a lot of space.

  • I have a bunch of numbers in my JSON data array like so...

    "achievements_unlocked": [ 9, 5, 4, 6 ],

    Is there an easy way I can sort these numerically? eg(4,5,6,9)

    Cheers

  • SOLVED:

    Change the line:

    JSON_MAIN: Set JSON_MAIN.CurrentValue to 9999

    to

    JSON_MAIN: Set JSON_MAIN.Path to 9999

    (which actually changes the value of the current path)

  • I am looping through a bunch of JSON values and if a value equals 1 I am trying to set it to 999 by using set JSON.CurrentValue.

    However, when I print the current value straight after this 'set' command it still prints as 1.

    here is the code as text..

    + JSON_MAIN: For each entry in "profile_"&Current_Profile&".achievements_unlocked"

    ----+ System: JSON_MAIN.CurrentValue = 1

    -----> JSON_MAIN: Set JSON_MAIN.CurrentValue to 9999

    -----> Browser: Alert JSON_MAIN.CurrentValue (This Alert prints 1???? I expect 999)

    Anyone know what I'm doing wrong?

    Thanks

Grimmy's avatar

Grimmy

Member since 20 Nov, 2012

Twitter
Grimmy has 2 followers

Trophy Case

  • 12-Year Club
  • Forum Contributor Made 100 posts in the forums
  • Regular Visitor Visited Construct.net 7 days in a row
  • RTFM Read the fabulous manual
  • Great Comment One of your comments gets 3 upvotes
  • Email Verified

Progress

17/44
How to earn trophies