XHXIAIEIN's Forum Posts

  • This is very simple in C3.

    Use build-in Date Plugin #open=date-time

    Example:

    Date.ToTotalHours(Date.Difference(Date.Parse("2023-11-15"), Date.Parse("2023-11-20"))) / 24

    If you also need to display localized currency units, then this will also be helpful to you #open=internationalization

    ---

    OR You can use Javascript to calculate, Here is an example:

    function calculateDaysDifference(userDate) {

    const startDate = new Date('2023-11-15');

    const endDate = new Date(userDate);

    const diffInTime = endDate.getTime() - startDate.getTime();

    const diffInDays = Math.floor(diffInTime / (1000 * 3600 * 24));

    return diffInDays;

    }

    ---

    Example:

    calculateDaysDifference('2023-11-20')

    Output:

    5

    ---

    But if you are talking about C2, you may need to use Brower to execute JavaScript.

  • Use @import url(). this works for me.

    CSS
    @import url("https://fonts.googleapis.com/css?family=Amatic+SC:400,700");
    body { font-family: 'Amatic SC', sans-serif; font-size: 2em; }
  • It may be related to your browser Version or computer hardware configuration. You can post your computer hardware information. This can help you find a problem better

    Or you can try to turn off the UI animation and Effect in the settings, which can also reduce the use of memory.

  • Icons in text example: #open=icons-in-text

    Animation Tag [icon=piggy]
    Animation Frame [icon=1] same as [icon=monster]
     
    BBCode Set Size: 
    [size=32][icon=piggy][/size]
    [size=64][icon=piggy][/size]
    
    BBCode Adjusting vertical alignment: 
    [icon=piggy]
    [iconoffsety=0][icon=piggy][/iconoffsety]
    [iconoffsety=50%][icon=piggy][/iconoffsety]
    
  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Tom The Steam deck desktop mode comes with an app store called discover. I found that there are several game engines in it, but Construct is not on the list. In fact, Recently my laptop broke and I have been using steamdeck to run Construct for 2 weeks and everything is fine. I think we can put a version on discover, maybe it can attract some new users.

    apps.kde.org/discover

  • Thanks! it can works.

    This function gets the color value from 0-1, which needs to be converted to 0~255.

    function convertTo255(value) {
     return Math.round(value * 255);
    }
    
    const ALPHAEX_SHIFT = 1024;
    const ALPHAEX_MAX = 1023;
    const RGBEX_SHIFT = 16384;
    const RGBEX_MAX = 8191;
    
    const RGB_MASK = [255, 65280, 16711680];
    const RGB_SHIFT = [0, 8, 16];
    const RGB_FACTOR = [RGBEX_SHIFT * RGBEX_SHIFT * ALPHAEX_SHIFT, RGBEX_SHIFT * ALPHAEX_SHIFT, ALPHAEX_SHIFT]; 
    
    function getColorValue(rgb, index) {
     if (rgb >= 0) {
     return (rgb & RGB_MASK[index]) >> RGB_SHIFT[index];
     } else {
     let v = Math.floor(-rgb % RGB_FACTOR[index] / RGB_FACTOR[index] / ALPHAEX_SHIFT);
     if (v > RGBEX_MAX) v -= RGBEX_SHIFT;
     return v / 1024;
     }
    }
    
    function GetRValue(rgb) {
     return getColorValue(rgb, 0) / 255;
    };
    
    function GetGValue(rgb) {
     return getColorValue(rgb, 1) / 255;
    };
    
    function GetBValue(rgb) {
     return getColorValue(rgb, 2) / 255;
    };
    
    function isNegativeZero(n) {
     return Object.is(n, -0);
    }
    
    function GetAValue(rgb) {
     if (isNegativeZero(rgb))
     return 0;
     else if (rgb >= 0)
     return 1;
     else {
     const v = Math.floor(-rgb % ALPHAEX_SHIFT);
     return v / ALPHAEX_MAX;
     }
    };
    
    function convertTo255(value) {
     return Math.round(value * 255);
    }
    

    Use:

    //------------------------------------------------
    // Set Global Var
    //------------------------------------------------
    const colorValue = runtime.globalVars.colorValue;
    runtime.globalVars.r = convertTo255(C3.GetRValue(colorValue));
    runtime.globalVars.g = convertTo255(C3.GetGValue(colorValue));
    runtime.globalVars.b = convertTo255(C3.GetBValue(colorValue));
    
  • Converting a colorValue back to RGB 255:

    R = int((-colorValue / 2^38) % 1025 * 255 / 1023)

    G = int((-colorValue / 2^24) % 1025 * 255 / 1023)

    B = int((-colorValue / 2^10) % 1025 * 255 / 1023)

    A = int((-colorValue) % 1025 * 255 / 1023)

    I tested using some colors but the formula didn't give the expected results

    -> System: Set colorValue to Sprite.ColorValue

    const colorValue = runtime.globalVars.colorValue;
    runtime.globalVars.r = Math.round((-colorValue / Math.pow(2, 38)) % 1025 * 255 / 1023);
    runtime.globalVars.g = Math.round((-colorValue / Math.pow(2, 24)) % 1025 * 255 / 1023);
    runtime.globalVars.b = Math.round((-colorValue / Math.pow(2, 10)) % 1025 * 255 / 1023);
    runtime.globalVars.a = Math.round((-colorValue) % 1025 * 255 / 1023);
    
    White (255, 255, 255)	// -281492157629439 -> (255,4,196,60)
    Dark(10, 20, 30)		// -10996458578943 -> (10,116,220,36)
    Grey(128, 128, 128)		// -141295868185599 -> (128,122,218,37)
    Red(255, 0, 0)			// -281474976711679 -> (255,4,192,63)
    Green(0, 255, 0)		// -17179870207 -> (0,255,4,251)
    Blue(70, 59, 222)		// -77244652187647 -> (70,216,94,161)
    
  • Ashley I'm confused about the ColorValue expression, which returns an integer that contains negative numbers. Is there a way to convert it to a regular color value?

    For example, Allow expression input parameters:

    ColorValue("R")

    ColorValue("G")

    ColorValue("B")

    ColorValue("A")

  • Maybe the Timer behavior could add an "exact calculation" property that is enabled by default. People who are more performance-critical can disable it to get a limited version of a timer?

  • I often use Timer instead of Function because it provides a delayed execution solution.

  • > There is also a developer who improved this weapp-adapter: github.com/finscn/weapp-adapter/blob/master/README_EN.md

    That link lists 5 known bugs in the WeChat game library, some look really nasty and difficult to work around, and I bet if we ported Construct we'd find a lot more. So I think my intuition was correct - supporting it would be a nightmare!

    I also tried to contact the mini games team but there was no news. They simply ignored my request because I was just a small user. But Other HTML 5 engines have already provided corresponding solutions, many of which are open source.(I linked to their code base in my previous post). Maybe Construct can reduce a lot of troubles on this road.

    But considering the current situation, I will not insist on this topic, because taking up too much energy in there may cause other plans behind C3 to be postponed indefinitely.

    I will continue to try to contact the mini games team to see if they can provide some technical support or support webview.

  • > The running environment of the mini game on iOS is JavaScriptCore, V8 on Android, they are all running environments without BOM and DOM, and there are no global document and window objects. Therefore, when you want to use the DOM API to create elements such as Canvas and Image, an error will occur.

    Yes, it doesn't support webview so they provide an 'adapter' to simulate a browser environment. Convert the DOM into their environment via the WXAPI provided by the adapter.

    There is also a developer who improved this weapp-adapter: github.com/finscn/weapp-adapter/blob/master/README_EN.md

  • Hi, Ashley! Please forgive me for still insisting on continuing to promote this topic. In fact, I noticed that in the development documentation of the mini game, there is an weapp-adapter which may be used to simulate the support of the browser environment.This might help support efforts, would you like to check it out again?

    you can download this: res.wx.qq.com/wxdoc/dist/assets/media/weapp-adapter.9568fddf.zip

    ---

    The article also mentioned some other HTML5 engine adaptation solutions. For example:

    If contact the minigame official, can even provide some public code of the C3 runtime library, which will help reduce the package size. Because minigame requires that the game package size cannot be larger than 4M:

    developers.weixin.qq.com/minigame/dev/guide/base-ability/game-engine-plugin.html

    --

    Wechat miniprogram

    github.com/stackOverMind/WeApp-adapter

    --

    Or is there any way to let third-party developers complete this work? Any good suggestions if I'm going to hire some professional programmer to do this? Because the adapter does not work like a plug-in, should we export HTML5 first and then write it manually?

  • Tom Currently a lot of old broken addons are still sorted to top making discoverability a bit bad. They are no longer applicable in the current version, or the original author has given up maintenance.

    Hopefully that a filtering rule can be added to only base on the voting in the recent year - and make it the default. so that new plugins are more likely to be seen, rather than historical accumulated votes.