MikaelS's Recent Forum Activity

  • I am iterating through a very large array using For each element. Because of the size of the array and the calculations done to its contents this takes a long time, and I would like to show some kind of progress to the user during the calculations. The problem is that For each element locks the operations. Neither setting a text nor logging to the browser works within the iteration. I've tried other ways, like inserting a wait statement or updating a global variable which is shown from another event, but without success.

    How can I show how far the iteration has gone during a For each element event?

    Tagged:

  • I am using the custom movement behaviour to move a sprite. The player can drag the sprite, and when it is released, it starts slowing down using the tween behaviour to reduce the speed of the custom movement until the sprite stops completely. This works fine.

    Under some circumstances, I want to restrict the position of the sprite and stop it immediately if it passes outside certain x and y coordinates. For this I use the linear stepping mode of the custom movement behaviour with the step size set to 1 pixel. On each step (using the On Custom Step event), I compare the position of the sprite to the limits and sets its speed to 0 as soon as it passes outside these borders. This, however, does not work.

    Apparently the custom movement uses the same speed for all steps during one tick, even if the speed is changed during one of the steps. Is this a bug or the intended behaviour? In my opinion, it makes the use of multiple steps per tick a bit less useful. Of course, it can still be used for pushing out of a solid, but it prevents other ways of using this behaviour for pixel perfect movement.

  • AllanR

    Thanks a lot for the answer and the fantastic example. The reason that I was pasting the hexes to the canvas instead of using them directly was that I had imagined that having thousands of sprites as tiles would be a performance problem. However, this was not the case, and I am now using animated hexes for the map and still have 60 FPS.

    Thanks!

  • I am creating a hex based, static map by pasting hex shaped sprites on a very large drawing canvas. The hex shaped sprite has one animation with a number of different frames, each frame representing different terrain. Before pasting each sprite, I get the current terrain type from another object, change the current animation frame of the sprite to the correct number and then paste it to the canvas.

    Here is a simplified example code for pasting a column of hexes (instead of getting the correct frame from the world map, I simply calculate it from the current row):

    + System: For "CurrentRow" from 0 to RowsNeeded

    -> Hex: Set position to (CurrentColumnCenterX, LoopIndex("CurrentRow") × Self.Height + RowOffset)

    -> Hex: Set animation frame to LoopIndex % Hex.AnimationFrameCount

    -> HexMapCanvas: Paste object Hex without effects

    Everything works fine, except that all hexes in the map are the same. They all turn out the same way as the last hex of the last column. There is a warning on the Paste object action stating that: "If an object is destroyed the same tick that you paste it, it will not be drawn, since drawing happens at the end of the tick." I assume that this also is the reason for all pasted objects looking the same, and therefore this is the intended behaviour and not a bug. Is that correct? In that case I have a workaround for this.

  • I am trying to detect which line of text a user clicks on in a Text object. To do this, I start by calculating the Y position of the click relative to the Text object's origin, but the problem is then how to convert this Y value to a line number. In order to do this, I would have to get either the height of each line, or the total number of lines of the text (including automatic wrapping done by the Text object) and then calculate the height of each line from the TextHeight.

    Although I haven't tried, it seems that the CharacterHeight expression could have been used for this purpose, if I had used a SpriteFont object instead. However, I prefer using the Text object because of its better unicode support, and unfortunately the CharacterHeight expression is missing from the Text object.

    Is there a way of accessing the height of each line, or the number of lines of (wrapped) text, of a Text object? Perhaps I am missing something obvious here?

  • Here is a small example with a layout consisting only of a Text, a Button and an Array:

    And of course, BBCodes will only work if you use the Construct 3 runtime for your project. You also have to remember to check the "Enable BBCode" checkbox of the Text - this is very easy to forget!

    Edit: of course, you could also store the text including the BBCode inside the array. However, from your example I got the impression that this wasn't what you wanted to do.

  • If you are using the C3 runtime, the easiest option is to use bbcode:

    https://www.construct.net/forum/construct-3/how-do-i-8/bbcode-text-formatting-feature-134131

  • Thanks for the answer. However, I realize that I wasn't very clear when I asked my initial question. I know where to set the project ID in the editor, but I want to access it from within the program. But I haven't found a way to do that. There doesn't seem to be a matching system expression.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Can the project ID be accessed somehow? There are system expressions for project name and version, but I haven't found any for project ID.

  • I have now posted a bug report for the original problem here:

    https://github.com/Scirra/Construct-3-bugs/issues/1902

    Thanks for the help!

  • I have been away for a couple of days, and haven't had the time to make a small test project until now. And when I finally did, I ran into another bug which I have just submitted a report for here:

    https://github.com/Scirra/Construct-3-bugs/issues/1901

    This new bug prevents me from testing the original On kicked bug on the Construct 2 runtime, but hopefully I can still test it on the new Construct 3 runtime and post a bug report later tonight.

  • Thanks Eindbaas and Krapfenmann for confirming that there is something wrong with the On kicked event. I suppose that this is a bug and will file a report.

    During additional testing I have also found that Multiplayer.PeerCount doesn't update properly when a peer is kicked. The PeerCount is reduced by one on the host, but on the other peers, the number stays the same. It seems that the peers aren't notified that another peer has been kicked. Perhaps this is related to the On kicked event not being triggered?

MikaelS's avatar

MikaelS

Early Adopter

Member since 21 Feb, 2017

None one is following MikaelS yet!

Trophy Case

  • 7-Year Club
  • RTFM Read the fabulous manual
  • Email Verified

Progress

9/44
How to earn trophies