Zathan's Forum Posts

  • I often need to work with arrays and JSON, using them for data structure conversion, more complex filtering, sorting, and more. However, the Eventsheet ACE functionality is limited and operations can be complex. Using JavaScript can save a lot of time.

    So, I use a function that takes Array.AsJSON and converts it into a true array using JavaScript. Then, I process the data internally, convert it back to a string, set the return value, and then make Array Load.

    > const array = JSON.parse(localVars.arrayJson);
    ...
    runtime.setReturnValue(JSON.stringify(array));
    

    This part of the JavaScript is perfect for AI to help. Simply tell it the data structure you want and the desired result, and it will handle it perfectly.

    Hmmmm that's an interesting point. Can we always use js/ts to handle array and object logic instead of events (wich are kind of limited and complex for this)? Like, if i need to create an object to store some weapons data, can i do this with ts and then use this object in events? It would be an awesome mix.

  • > we could need something like: "LOW", "MEDIUM", "HIGH"

    So just make a string variable that you give these 3 values? Or use integers? I don't think you need a specific variable type for that at all. Same for yes/no.

    Imagine that you have a variable called size, wich can receive "LOW", "MEDIUM" or "HIGH", but by mistake at some point you assign "HIG" for it, or even another value that you tought you could, like "HUGE". It won't work and maybe the problem will not be obvious for you when it happen.

    Typescript can fix that, cause you can type this variable like this:

    let size: "LOW" | "MEDIUM" | "HIGH"

    this way, if you assign anything else to this variable, your project won't even run and the problem will be shown.

  • Haven't construct variables been typed since the beginning of time?

    Maybe simple types, like number, string, etc, but what if we need a variable that can receive either "YES" or "NO"? we can achieve this with TS, but not with events.

    ps: yes/no could be fixed with a boolean var, but we could need something like: "LOW", "MEDIUM", "HIGH".

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Rojo's reply made me realize another thing: with typescript code, you can have typed code, wich is not possible with events. That's interesting.

    Awesome, thank you very much guys.

  • I’m getting back to Construct after a while and noticed that now we even have the option to code with JS/TS. At first, I thought it was interesting, but then I started wondering: why? Is it just for people who prefer writing code, or are there other benefits? Are there things that work better or perform better through code? Are there things you can do with code that aren’t possible with events? Thanks!

  • Congratulations, dude! It looks awesome.

  • Zathan if your Douglas Duarte

    Ive given access for you todowload the file

    Hey man, thank you very much! I think this is the way to go. I will play a little with this addon and try to make a cool effect for pixel art.

  • Ok, didn't knew about the normalmap addon. But still, how could some kind of light source interact with it to create the effect? i don't even know if it's some super advanced effect or not. lol

  • you mean how to make it?

    Yes. I mean, the guy made it with c3, but i don't have a clue how to achieve an effect like that.

  • Subscribe to Construct videos now

    Do you guys have any clue how to achieve a lighting effect like this for pixel art? It blew my mind when i saw this video.

  • I know it's super simples to get every instance of an object that have a specific property or tag, but how can i get all the instances of all objects that have a tag?

  • Thank you very much for the help, guys!

    Very cool system, paxclara. Probably i will go this way too for now.

    For the Construct team: C3 is AWESOME, but i think this is some of the most basic needs of every game developer. The input and rebind system of a game need to be robust. It would be so good if you guys could add this in a future update!

  • In most game engines, there's typically a system to create key/action mappings like:

    {
    	"jump": "Spacebar" | "Gamepad A",
    	"interact": "E" | "Gamepad B"
    }
    

    This allows developers to reference actions like "jump" in the code, instead of hardcoding specific key presses, and easily modify key bindings at runtime so players can remap controls as they prefer.

    However, it seems that Construct 3 doesn't have a built-in system like this, which seems a little weird to me.

    Is there currently a way to achieve this functionality in Construct 3?

    Thanks!

    Tagged:

  • I'm guessing you have different events for different sprites?

    Mouse -> On Sprite1 clicked -> (start dragging Sprite1)

    Mouse -> On Sprite2 clicked -> (start dragging Sprite2)

    etc.

    Just create a flag (a global variable) isDragging. Set isDragging=1 when a sprite is clicked, reset to 0 when it's dropped.

    Add a second condition to all these events:

    System-> isDragging=0

    Or if all these draggable sprites are in a family, and you have just one event (Mouse->On DraggableFamily clicked), add DraggableFamily->Pick Top Instance as a sub-event.

    Yeah!

    It worked very well

    Thank you!

  • I'm making a custom drag n drop behavior with events, without using the built-in behavior that is very limited. I'm using physics and the touch object. Everything is working fine, except for one thing:

    I disabled collisions between the draggable objects, so they can overlap each other. And here is the problem... when there is more than one draggable objects overlapping each other, if I click to drag, everyone is activated, not just the top one. And it is different sprites, not just different instances of the same... so I just can't figure out how to work around that.

    How can I manage to fix this?