MikaelS's Forum Posts

  • 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.

  • 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?

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • I am experimenting with the Multiplayer plugin but as far as I can tell, the On kicked event never triggers on the peer side when the peer is manually kicked by the host using Multiplayer Kick peer (it does trigger if the host leaves though).

    The background is that I allow an unlimited number of peers to connect to the room. The host is able to lock and unlock the room dynamically, and admission of new peers is controlled using this code on the host side:

    On the peer side, I want to detect if the peer was kicked. This is done using this code:

    On the host side, the code works as intended and the peer isn't allowed to join, but on the peer side, the On kicked event apparently isn't triggered. As a workaround, I am sending a message (tagged as Game Locked) from the host, but I would have guessed that this should have been unnecessary.

    Just in case, I have also tried waiting for up to several seconds before kicking the peer, but the event is still not triggered on the peer side.

    Am I doing something wrong or is this a bug?

    (Edited to more clearly explain that the On kicked event does trigger when the host leaves, but not when the peer is kicked manually)

  • I intend to use (local) boolean variables to keep some intermediate results from a number of calculations, but can't find how to set the value of the local variables that I want to use. I can't use System->Set value, since the boolean local variables aren't shown in the variable drop down list. I can't use System->Set boolean either, since then I am ony allowed to choose between True and False and can't enter an expression which is what I want.

    How should I do this? Most likely I am missing something simple!

  • Thanks for your answers. I realized that I had overcomplicated things and was able to make it work. Construct is amazing, but it takes some time to get used to it!

  • I am new to Construct 2 but not to programming. As a small test, I have implemented "zoom towards mouse pointer" like in Google Maps.

    As target for the zoom, I use a Sprite. Since I want to be able to change this sprite dynamically, to a sprite with a different size and different aspect ratio, I have set the layout size to a very big value and handle scale limiting when zooming out myself. As far as I have found out, it is impossible to change the size of the layout itself at runtime.

    When the user zooms out using th emouse wheel, the layer scale of the sprite is changed, and ViewportLeft, -Right, -Top and -Bottom are used to detect if any edge of the sprite is inside the visible area. In that case, scrollx and scrolly are adjusted accordingly.

    Sooner or later when zooming out, both the opposite sides of the sprite become visible, and therefore, a minimum scale (maximum zoom out) that can be allowed has to be calculated. I do this by dividing Browser.ScreenWidth by the width of the sprite. I then do the same for height and choose the maximum value as the limit. All this works fine, as long as the browser covers the entire screen.

    However, if the user resizes the browser, the above scale limit calculation stops working. The problem here is that the browser itself (I have tested with Google Chrome) automatically scales the contents when the browser window is resized. This automatic scaling breaks the calculation and I have found no way to handle this.

    I can see three different solutions:

    • somehow find the automatic scale change and compensate for this mathematically (best),
    • somehow stop the browser from scaling the contents automatically (acceptable),
    • somehow prevent the user from resizing the browser window (worst).

    Can anyone suggest how this could be done, or if there are better ways to do it? Is it possible to determine the value of the automatic scaling that the browser applies?

    Thanks in advance,

    Mikael