You can do something like this with mesh and mask
Develop games in your browser. Powerful, performant & highly capable.
Playing with mesh distortion
https://www.patreon.com/posts/mesh-shapes-47493518
github
https://c3demo.stranianelli.com/javascript/009-mesh-and-shapes/demo/
You can use IWorldInstance.setMeshPoint(col, row, opts) to set mesh point position. But what if I want get the point position?
I want do something like this:
PSEUDOCODE:
function lerpMeshPointPosition(instance, t, { col, row, newX, newY } = {}) { const startX = instance.getMeshPoint(col, row, "absolute").x; const startY = instance.getMeshPoint(col, row, "absolute").y; const lerpedX = lerp(startX, newX, t); const lerpedY = lerp(startY, newY , t); instance.setMeshPoint(col, row, {mode: "absolute", x: lerpedX , y: lerpedY }); }
Did you intend in js?
const myArray = ["Zero", "One"]; const index = 0; console.log(myArray[index]);
See https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array
Instead if you intend the plugin array see https://www.construct.net/en/make-games/manuals/construct-3/scripting/scripting-reference/plugin-interfaces/array
const myArray = runtime.objects.array.getFirstInstance(); console.log(myArray.getAt(0));
huras
You can use something like this
runOnStartup(async runtime => { globalThis.publicRuntime = runtime; });
Use this
export function printTextToOutput() { const instance=g_runtime.objects.textOutput.getFirstInstance(); instance.text = text; }
and in main.js
runOnStartup(async runtime => { globalThis.g_runtime = runtime; });
See this https://www.patreon.com/posts/construct-3-46901116 for the g_runtime
(O qui, in italiano https://blog.stranianelli.com/new-template-construct-3-youtube/)
You can declare this also in print.js
You can do something like this (I'm writing from my smartphone, I can't test this code now)
export function printTextToOutput() { const instance=runtime.objects.textOutput.getFirstInstance(); instance.text = text; }
And in the event sheet call Printer.printTextToOutput() when textOutput is created
You can check this https://www.construct.net/en/make-games/manuals/construct-3/scripting/scripting-reference/object-interfaces/iobjectclass
È Martin Mystere quello nel tuo avatar?
What do you mean with "only js"? Without event sheets?
Have you seen the event sheet "printer"?
If you want, you can check the Ghost Shooter Template
Try this links
https://github.com/el3um4s/construct-demo/tree/master/mini-template/001-execute-a-function-from-separate-event-sheet
— See this:
https://c3demo.stranianelli.com/mini-template/001-execute-a-function-from-separate-event-sheet/source/c3p/execute-a-function-from-seprate-event-sheet.c3p
https://c3demo.stranianelli.com/mini-template/001-execute-a-function-from-separate-event-sheet/
https://c3demo.stranianelli.com/mini-template/001-execute-a-function-from-separate-event-sheet/demo/
It depends on what you want to achieve. You can embed a procedure in a function to be performed only when necessary, when you decide
619_RM
You can use https://www.construct.net/en/make-games/manuals/construct-3/scripting/scripting-reference/object-interfaces/iworldinstance
https://twitter.com/el3um4s/status/1357263976007143428
Thank you :)
How can I get the dimensions of a mesh?
I can create a new object with
const objectInstance = runtime.objects.Key.createInstance("Keyboard", 200, 150);
But how can I create the hierarchy?
Is there such a thing as this?
const objectInstance = runtime.objects.Key.createInstance("Keyboard", 200, 150, {hierarchy: true});