BigBuckBunny's Forum Posts

  • If I understand correctly, you want to load multiple images from different urls in a single sprite (or multiple images from a single URL? Is that even possible?)

    Suppose you want to load 2 different images from 2 URLs to a single sprite. There are 2 ways to do it:

    1) create a sprite. Load the first image onto the sprite. Paste the sprite on a drawing canvas. Now load the second image on the same sprite, and paste it again on the canvas, with an offset. You now have a canvas with both images combined

    2) Use scripting to create an html canvas and two images. load the images content, and paste it to the canvas. then, turn the canvas into a dataURL. Delete the canvas and use the dataURL as input to the "load from URL" action for your sprite. You now have a sprite with both images combined.

    Code for number 2.

    const imageUrl1 = "https://i.imgur.com/ylpLIoJ.jpeg";
    const imageUrl2 = "https://i.imgur.com/pwbUJwD.jpeg";
    
    const canvas = document.createElement('canvas');
    canvas.id = 'canvas';
    canvas.width = 500;
    canvas.height = 500;
    document.body.appendChild(canvas);
    
    const ctx = canvas.getContext('2d');
    
    const img1 = new Image();
    const img2 = new Image();
    
    img1.crossOrigin = 'anonymous';
    img2.crossOrigin = 'anonymous';
    
    // images are drawn onto the canvas, which is then turned into a dataURL that Construct can work with.
    img1.onload = () => {
    	ctx.drawImage(img1, 0, 0, 250, 250); // Draw first image
    	img2.onload = () => {
    		ctx.drawImage(img2, 250, 0, 250, 250); // Draw second image
    		const dataUrl = canvas.toDataURL('image/png');
    		runtime.callFunction("LoadImageFromDataURL" , dataUrl);
    		canvas.remove();
    	};
    	img2.src = imageUrl2;
    };
    img1.src = imageUrl1;
    
  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • You can achieve that using Array + Local Storage.

    Suppose you have 10 levels. Create an array (1D) of size 10. The index of each element will be the index of the level, and the element at that index will be the number of stars assigned to the player for that specific level.

    Ex: [2,3,3,-1,-1,-1]. Level 0 was completed with 2 stars, level 1 with 3 stars, level 2 with 3 stars, and level 3,4,5 are not completed.

    In Construct you can't explicitly store arrays using data storage, but you can store text. By converting the array into a JSON and then storing the JSON, you can effectively store an array, represented as a string.

    When you get your data back, you just need to load the JSON into the array.

    Here's a working example: dropbox.com/scl/fi/sxcybgz2948554akfm3gv/Level-Stars.c3p

  • Sometimes when i use tilemap an I run the project some tiles are replaced by black squares. I didn't use the event sheet.

    Here's two photos, one when i'm in construct 2, and one when i run the project.