ComGamer's Recent Forum Activity

  • Is it possible to open a local (on Windows & Android) audio file and play it?

    With the FileChooser I can "load" a sound, but how can I play it?

    Wim

  • Hi,

    I want to draw on a html canvas:

    const topCanvas = document.createElement("canvas");

    document.body.appendChild(topCanvas);

    But the canvas is always positioned on the window and i can't find a way to position it relative to the viewport or layout:

    topCanvas.style.position = "absolute";

    topCanvas.style.left = "10px";

    topCanvas.style.top = "10px";

    topCanvas.style.width = "500px";

    topCanvas.style.height = "500px";

    thanks!

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Ashley,

    I'm sorry I did not make myself clear (my last reply contained your solution not mine):

    - These are no onkeypressed functions in my layoutspecific eventsheets.

    In the common eventsheet there are 8 onkeypressed functions, but on the layout-specific eventsheets there is only one 'function that does all the action' with the 'keyboardkey' as parameter.

    So there are no duplicate functions in my example.

    Number of functions in the project:

    - Your solution:

    (3 layouts) x (8 'onkeypressed functions' + 1 'function that does all the action')

    = 27 functions.

    --> a lot of duplicated code

    My solution:

    (8 common onkeypressed functions) + ((3 layouts) x (1 'function that does all the action'))

    = 11 functions.

    --> no duplicated code

  • Fengist, Ashley, Thank you!

    Fengist: I'm not a native speaker, so I miss the subtle difference between English words, but 'functional' is indeed a better word to describe what I want. :-)

    So I have to put all keyboard events in all layouts. In my project this seems like a lot of double code. Maybe I made my example to simple, so I try to explain myself better:

    - I'm making a game for children with a motor disability, so they have to access it by keyboard.

    - It's a game about recognizing colors.

    - They can choose a color by the corresponding key (r: red, g: green, y: yellow, p: purple, ...).

    - On layout1 when they press 'r' a red balloon pops.

    On layout2 when they press 'r', the red airplane makes a loop,

    on layout3 when they press 'r' the red helicopter flies away, ...

    - So every layout contains a keyboard event and a corresponding function:

    My current "common Eventsheet" contains:

    Keyboard(On [r] Pressed) -→ keyPressed(Red)

    Keyboard(On [o] Pressed) -→ keyPressed(Orange)

    Keyboard(On [g] Pressed) -→ keyPressed(Green)

    Keyboard(On Pressed) -→ keyPressed(Blue)

    Keyboard(On

    Pressed) -→ keyPressed(Purple)

    Keyboard(On [y] Pressed) -→ keyPressed(Yellow)

    Keyboard(On [w] Pressed) -→ keyPressed(White)

    When I define this in every layout I get:

    On ES1:

    Keyboard(On [r] Pressed) -→ keyPressed1(Red)

    Keyboard(On [o] Pressed) -→ keyPressed1(Orange)

    Keyboard(On [g] Pressed) -→ keyPressed1(Green)

    Keyboard(On Pressed) -→ keyPressed1(Blue)

    Keyboard(On

    Pressed) -→ keyPressed1(Purple)

    Keyboard(On [y] Pressed) -→ keyPressed1(Yellow)

    Keyboard(On [w] Pressed) -→ keyPressed1(White)

    On ES2:

    Keyboard(On [r] Pressed) -→ keyPressed2(Red)

    Keyboard(On [o] Pressed) -→ keyPressed2(Orange)

    Keyboard(On [g] Pressed) -→ keyPressed2(Green)

    Keyboard(On Pressed) -→ keyPressed2(Blue)

    Keyboard(On

    Pressed) -→ keyPressed2(Purple)

    Keyboard(On [y] Pressed) -→ keyPressed2(Yellow)

    Keyboard(On [w] Pressed) -→ keyPressed2(White)

    ...

    Is this the most functional way?

  • blackhornet

    Thank you, but the problem is that the functions are more complex than this, I've drastically simplified it. In your solution the ES_common has to know what's going on in L1 & L2.

    ES_common has to make a 'generic call' to the corresponding functions in the other eventsheets.

    The corresponding functions can do a lot of different things like creating new sprites & particles, destroy sprites, ...

    Both layouts are a kind of 'mini-game' which are very different, but every layout uses the same keyboard keys.

    Wim

  • Is mapping the function to a string the simplest way?

    ES_Common:

    + System: On start of layout

    -> Functions: Map "mymap" string "moveSpriteL1" to moveSpriteL1

    -> Functions: Map "mymap" string "moveSpriteL2" to moveSpriteL2

    + Keyboard: On Space pressed

    -> Functions: Call function from "mymap" map with string "moveSprite" & LayoutName (forward parameters from index 0)

    ES1:

    * On function 'moveSpriteL1' -> Sprite1: Move forward 20 pixels

    ES2:

    * On function 'moveSpriteL2'-> Sprite2: Move forward 20 pixels

  • Hi,

    I have two layouts (L1 & L2) with both an eventsheet (ES1 & ES2) and one common eventsheet (ES_common) that's included in both ES1 & ES2.

    In ES1 & ES2 there is an event MoveSprite.

    Is ES_common I have an event Keyboard(On [Space] Pressed).

    What I want is to call 'MoveSprite' from ES_common.

    If L1 is active it has to call 'MoveSprite' in ES1.

    If L2 is active it has to call 'MoveSprite' in ES2.

    Before the new build in function it worked. But now two functions can't have the same name.

    My workaround now is to create two functions moveSprite1 & moveSprite2.

    In ES_Common is use two conditions:

    LayoutName = "L1" -> Call moveSprite1

    LayoutName = "L2" -> Call moveSprite2

    (This is of course a very highly simplified project)

    Is there a more elegant way to solve this?

    project file: drive.google.com/open

    Thanks

    Wim

    Tagged:

  • Snipg Thanks, I'll try this!

    Wim

  • Thanks,

    Make the Drawingcanvas much smaller to prevent crashing, this reduces the number of iterations.

    I already tought about using a sprite but

    the problem with using sprites is that I can't change the gradient of the sprite while running, I think. Or I have to limit to a few gradients.

    And I wonder why the loop in js is so much faster it can keep up with mouse movements.

    Wim

  • Hi,

    Is it possible to manipulate the pixels in a DrawingCanvas at much higher speed, redrawing every mouse movement? Or is manipulating pixels at high speed possible with another object?

    What I want to achieve eventually is a heatmap-drawing effect.

    I hope the c3p file makes my question clear:

    c3p: drive.google.com/file/d/1bzYRqDxKG2PJMvgfpW2TCtTBOohLenk3/view

    I simplified my code to focus on the manipulation of the pixels. The DrawingCanvas now gets another color every .1 second (pixel by pixel). But on my Windows laptop it's only two or three times/second.

    What I want is possible with js & html canvas. I included the html/js code in my project in an Iframe to show what I want to get.

    The loop in 'on snapshot' takes to much time for the html/js code to work, so disable this loop to see what I want to achieve!

    Thanks!

    Wim

  • I found an anwer to:

    [quote:2bvx22e1]Is there another way to clear all slots, for example in the settings of my browser?

    Clearing the localestorage of a specific site in Chrome:

    support.google.com/chrome/answer/95647

  • Hi,

    Thank you for the clear answer!

    [quote:1q3vlevq]In other words rather than deleting the save slot, you can delete the ability for a user to load a particular save.

    What about the Local Storage limits of the browser?

    Can I exceed the limits If I create new slots over and over again, with a lot of data?

    Is the slot limited or the application?

    Is there another way to clear all slots, for example in the settings of my browser?

    Thanks again!

ComGamer's avatar

ComGamer

Member since 20 Oct, 2017

Twitter
ComGamer has 1 followers

Connect with ComGamer