Delphawi's Forum Posts

  • Hello,

    I cannot get C3's AdMob to work, despite uploading the app to Google Play and linking it with AdMob.

    C3 keeps saying "Invalid server response" and that it cannot read publisher's data.

    I have copied the Android/iOS codes from AdMob and pasted them in C3 AdMob properties.

    What else should I check, please?

    Tagged:

  • The Keyboard's IsDown event will always trigger while the key is pressed. Maybe you can try Keyboard OnKeyPressed instead; which triggers only once when the key is pressed.

  • OK, I managed to get the AJAX plugin to work!

    The solution was to remove ALL "Set Request Header" actions, even for "Content-Type".

    Now using PostToURL action (with Method="GET"), or RequestURL action (and passing parameters in the url), Work!

    What I don't understand is, why did the headers cause the issue??

    Even after allowing the Content-Type header on the server, setting Content-Type header using AJAX plugin always causes the CORS issue again.

    Header set Access-Control-Allow-Headers "Content-Type"

    Thank you!

  • So I have used scripts. AJAX plugin is still not working, but the script works!

    The script dynamically loads ajax script from cdn at the start, and when the CallAPI function is called, it uses the ajax object to call the api.

    Here is the full code:

    const dependenciesURL = "http://ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js";
    
    // Load a script and append it to the document
    const LoadScript = (scriptUrl) =>
    {
    	return new Promise((resolve) =>
    	{
    		const script = document.createElement("script");
    		
    		script.addEventListener("load", () => resolve(true));
    		script.addEventListener("error", () => resolve(false));
    
    		script.src = scriptUrl;
    
    		document.body.appendChild(script);
    	});
    }
    
    // Load all project dependencies
    async function LoadDependencies()
    {
    	const sdkAvailable = await LoadScript(dependenciesURL);
    
    	if (sdkAvailable)
    	{
    		console.log("Dependencies ready");
    		
    		InitializeDependencies();
    	}
    	else
    	{
    		console.log("Dependencies not available");
    	}
    }
    
    // Initialize variables
    function InitializeDependencies() {
    	console.log("InitializeDependencies");
    }
    
    // Call the loading functions
    LoadDependencies();
    
    function CallAPI(_type, _url, _data){
    	$.ajax({
    		 type: _type, // GET
    		 url: _url,
    		 data: _data,
    		 
    		 cache: false,
    		 
    		 success: function(response) {
    		 	console.log(response);
    		 }
    	});
    }
    

    So the api works using the browser, postman, and javascript, but not the AJAX plugin. Any idea what is going on here?

    Thank you!

  • Hello

    I have made a simple api. I can call it using url in the browser, and I can use Postman to call it. No authentication required.

    The server is allowed to accept any origin:

    Header set Access-Control-Allow-Origin "*"

    Yet, C3 AJAX keeps telling me:

    Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at [...]. (Reason: CORS preflight response did not succeed). Status code: 422.

    Please help !

    Thank you :)

    Tagged:

  • Resize (Alt R)

    Change the size then edit the properties of Tilemap to the Tile Width and height you want

    Here is a quick video:

    https://youtu.be/ONq2oUUvQCg

    Thanks a lot. I think my question was not worded properly. I meant that I wanted to use the high-res version of the map without resizing.

    Similar to how we can use 1000*1000 sprite on a 10*10 instance.

  • Hello,

    I am making a game where the player re-arranges pieces of an image. I am using a tilemap for the image.

    I have a high-resolution tile map (1800*1800), and I want to use it in an instance that is 600*600. When using a sprite we can use a 1000*1000 sprite in the animation editor, and resize the instances as we like.

    Is it possible to do that with tilemaps? i.e. use high-resolution source image, but resize instances differently.

    Is there a way to do this?

    Thank you.

    Tagged:

  • Hello,

    I have AdSense script I want to add to the game's DOM on start of layout. I used javascript script to do that.

    It works in preview and the code shows when I view source, but no ads show up.

    When the game is uploaded to the server, I get this text in the source instead of the script that was correctly shown in preview:

    <noscript>
    		<div id="notSupportedWrap">
    			<h2 id="notSupportedTitle">This content requires JavaScript</h2>
    			<p class="notSupportedMessage">JavaScript appears to be disabled. Please enable it to view this content.</p>
    		</div>
    	</noscript>

    I checked browser settings, and JavaScript is enabled all right.

    Any idea if this is a server issue or C3 issue, or maybe it is caused by the ad itself?

    Thank you!

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • I usually try to differentiate objects using layers or instance variables, so when a click happens, I pick only the object that has specific conditions met.

  • I don't see a need to use JSON, you could append all variables into a string and then run through it again with tokenat to set the values on another instance. Saving to a temporary or local variable to swap them is fine though.

    That's somehow what I did.

    But it took more time than needed. I hoped AsJSON could do the job in one line.

  • Is the initial instance created at runtime?

    No, both instances are created during edit time.

    Then at runtime, the player changes the instances' states and variables.

    At one point, I need to swap the states of 2 instances.

    I tried to use:

    state1 = instance1.AsJSON

    state2 = instance2.AsJSON

    instance1 -> Set From JSON (state2)

    instance2 -> Set From JSON (state1)

    But it didn't work.

    I had to set the state manually (i.e. save each instance variable to a temporary variable, then swap them, and so on...).

    My question is: is there a way to use Set From JSON to set ALL the instance variables (i.e. state, in general) at once, instead of 1 by 1?

  • If you want to make a copy of an object you can right click on it and use 'clone'

    Thank you.

    What I want is to make a copy of an instance of an object at run time, instead of cloning an object at edit time.

  • Hello,

    I am trying to swap 2 objects together (which have lots of instance variables), so I thought "Why not try Set from JSON?".

    I saved the AsJSON state of the first object in a variable, and used Set from JSON of the 2nd object, but the 2nd object disappeared.

    When I checked the stored JSON, it did not contain any data related to my variables.

    Is there a specific way for this action to work?

    Thank you!

    Tagged:

  • Hello,

    I couldn't find a way to find the specific collision point between 2 objects. Found this topic, but I can't reply in it because it is old.

    Here is what I tried, in case it helps anyone:

    You can create your own collision points and check using them.

    - At start of layout:

    -- For each Polygon point on your moving object A:

    --- Create a CollisionPoint object (a simple circle) at the polygon point X,Y

    --- Add the CollisionPoint object as a child to A

    - On CollisionPoint collision with another object:

    -- Do something

    Now you can control the distribution (shape and count) of CollisionPoint objects using the collision polygon.

    Note: there are sprite expressions now to get Polygon Point Count and Position of each.

    Update1:

    I just noticed that Physics has ContactXAt and ContactYAt expressions to get contact points. I might give it a try later.

    Hope this helps!

    Please let me know if there are more efficient ways.

    Thanks.

  • I have never seen this "Loops" section. I tried adding a few loops and recursive function calls in a test project and still don't see it in the debug view.

    Could you post a screenshot?

    Me too. It seems to be triggered by the aforementioned exception.

    I managed to replicate the behavior. It needs a recursive function with a loop. Here is the code and the result: