XHXIAIEIN's Forum Posts

  • I learn a example by R0J0hound in this post and re-made a example:

    cdn.discordapp.com/attachments/225550155531812865/1285262088108769280/load_spriteStrip.c3p

    This example will load a file containing sprite strip/sheet frames from the project's files.

    Then it will be displayed as a single frame in the game

    noted that: this example is not optimized. You can refer to what R0J0hound mentioned and use the drawing canvas to paste a single frame for better results.

  • WeChat also has two product directions. The other is WeChat Mini Program, which directly provides a webview environment. When C3 releases a mini program, if it does not need to use WeChat's API function, it will not need to do much work to release it.

    // index.wxml
    <web-view src='{{url}}' />
    
    // index.js
    Page({
    	data:{
    		url: "",
    	}
    })
    

    However, WeChat mini programs cannot publish game content, but they can be used to do some tool applications.

  • Does WeChat use a webview with a real browser engine like Chromium or WebKit? Or is it still based on a custom browser engine?

    As far as I know(link), WeChat Mini Games uses Chromium as the WebView rendering layer and V8 as the logic layer on Android. iOS uses WKWebView as the rendering layer and JavaScriptCore as the logic layer.

    However, they did not provide this environment directly, but encapsulated it. In the Android, they use a custom engine XWeb 126 (equivalent to Chromium 126) to rendering.

    The documentation still mentions Chromium 67, which means their staff hasn't updated the documentation for a long long time. All the documentation is very confusing and outdated. It's terrible to read.

    Therefore, the main task is to convert the Canvas API into WeChat's WX Canvas API.

  • I agree, The "Nth" it should be a relative number, not an absolute number.

    We should select the Nth child object of the same type relative to the parent object, rather than a specific one in the entire hierarchical family tree.

    In this (example.c3p), only the first event works, the others do not work as expected.

    I know that the yellow box has 3 blue box child object, so I just need to select the number via 0, 1, 2. Let's go a step. if i want to continue selecting the last red box of this blue, what should I do?

    If I have to save this index manually, It's much easier to use another system comparison condition.

  • I get some callbacks from some functions. I want to send a signal there, then receive the signal via the eventsheet and then continue to do something. But I can't seem to find a interface to do it.

    window.api.sayHello(data => {
     // do something
    });

    Update:

    A new signal() method, as well as waitForSignal() for allowing JavaScript code to also wait for a signal, is now available in r401.

    Now we can do

    window.api.sayHello(data => {
     runtime.signal("")
    });
  • 03: Allow move instances layer in the context menu

    It would be very convenient if we can move the instances to another layer in the Instance bar.

    04: Allow dragging instances into folders in any state

    Currently, only instances on visible, unlocked layers can be dragged into folders, which is inconvenient. I think it should have more freedom of operation.

  • 01: 'Scroll selection into view' Should be Keep Current Zoom Scale

    Currently, using'Scroll selection into view' will change the editor zoom. I think it should keep the zoom and just change the scroll position.

    02: Separately control the display and lock property of instance objects

    Currently, we can only control a layer, But it is not to target a specific instance.

    It would be more convenient if each instance could be controlled individually.

    (This is from the previous sketch)

    and add a common 'editor' property to all object types. Like the layers bar, can be hidden or locked for each object.

  • This example made by Connor Walker /tzl@stickfigya

    DonkeyKongMapSystem.c3p

  • CookingMatchIngredientsJSON-2.c3p

    you are no longer using an array to store ingredient data, there is no need to sort, just compare the Loop name and the amount.

    {
    	"Recipe": {
    		"TomatoEggSoup": {
    			"Ingredients": {
    				"Egg": 2,
    				"Tomato": 2,
    				"Water": 10
    			}
    		}
    	},
    	"Play": {
    		"Ingredients": {
    			"Egg": 2
    		}
    	}
    }
    
    const dataInst = runtime.objects.JSON.getFirstInstance();
    const data = dataInst.getJsonDataCopy();
    const recipes = data.Recipe;
    const playIngredients = data.Play.Ingredients;
    
    let result = "none";
    
    for (const recipeName in recipes) {
     const recipeIngredients = recipes[recipeName].Ingredients;
     if (Object.entries(recipeIngredients).every(([ingredient, amount]) =>
     playIngredients[ingredient] === amount)) {
     result = recipeName;
     break;
     }
    }
    
    runtime.setReturnValue(result);
    
  • CookingMatchIngredientsJSON

    I changed the structure of the recipe.

    {
    	"Recipe": {
    		"TomatoEggSoup": {
    			"Ingredients": [
    				"Egg",
    				"Tomato",
    				"Water"
    			]
    		}
    	},
    	"Play": {
    		"Ingredients": []
    	}
    }
    

    I use a JavaScript to match it. If a recipe is matched, return the key name. else or returns None. This name will correspond to your animation name.

    const dataInst = runtime.objects.JSON.getFirstInstance();
    const data = dataInst.getJsonDataCopy();
    const recipes = data.Recipe;
    const playIngredients = data.Play.Ingredients.sort().join(",");
    
    let result = "none";
    
    for (const recipeName in recipes) {
     const recipeIngredients = recipes[recipeName].Ingredients.sort().join(",");
     if (playIngredients === recipeIngredients) {
     result = recipeName;
     break;
     }
    }
    
    runtime.setReturnValue(result);
    
  • Since you already have a Json content to store the recipe.

    it might be like this:

    {
     "Pancake": { "id": 1, "ingredients": ["flour", "sugar", "milk", "egg"] },
     "Butter Cookies": { "id": 2, "ingredients": ["flour", "butter", "sugar"] },
     "Muffin": { "id": 3, "ingredients": ["flour", "sugar", "milk", "butter", "egg"] },
     "Cake": { "id": 4, "ingredients": ["flour", "sugar", "milk", "butter", "baking powder"] },
     "Cream Frosting": { "id": 5, "ingredients": ["sugar", "butter", "milk"] }
    }
    

    or like this:

    [
     {"id": 1, "name": "Pancake", "ingredients": ["flour", "sugar", "milk", "egg"]},
     {"id": 2, "name": "Butter Cookies", "ingredients": ["flour", "butter", "sugar"]},
     {"id": 3, "name": "Muffin", "ingredients": ["flour", "sugar", "milk", "butter", "egg"]},
     {"id": 4, "name": "Cake", "ingredients": ["flour", "sugar", "milk", "butter", "baking powder"]},
     {"id": 5, "name": "Cream Frosting", "ingredients": ["sugar", "butter", "milk"]}
    ]
    

    Or You can also join them into strings instead of using arrays.

    "ingredients": "flour,sugar,milk,egg"
    

    Then, a core processing step is to sort the materials and the recipes, so that players can add materials in any order and then match them with the recipes.

    "ingredients": ["flour", "sugar", "milk", "egg"]
    
    // sort
    ['egg', 'flour', 'milk', 'sugar'] 
    

    Then prepare a JSON to store the materials added by the player, and finally compare whether the two contents are the same.

  • TomLaura_D I find tutorials is full of spam posts, is it possible to clean them up regularly?

    I think some kind of content review mechanism should be added to convert some posts that are not related to tutorials into unpublished posts, so as to ensure the quality of the tutorial page.

    construct.net/en/tutorials/page-2

    Tagged:

  • ChatGPT doesn't understand what C3 does and will just say things that look correct but are not the same as what they actually do.

    ArrayCard.c3p

    ---

    if you want to import some card data, you can create an Array file and then load it into the Array object through AJAX.

    Uused for reference them as the card original database.

    In the game, you can have a other Array to manage the "current card", which stores the card ID. it determines the cards that player can currently use.

    If you want to exchange, that is, replace the IDs of these cards.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Can you upload your files?

    Do you know what tokenat actually does?

    tokenat("apples|oranges|bananas", 0, "|")

    returns apples.

    tokenat("apples|oranges|bananas", 1, "|")

    returns oranges.

  • As the screenshot prompts, the parameters of tokenat expression are filled in in the wrong.

    The correct usage is:

    tokenat(src, index, separator)

    tokenat(cardData, 0, "|")