Nilom's Recent Forum Activity

  • Hello past me. I have come across a working solution:

    On start of layout call the function that we define in the scripts.

    If there is no Token in the url the global variable access_token will only contain "Bearer ". In that case it will forward to the login-page.

    Here is how the Token is read from the url.

    window.location.href will return the full url. We slice out the part where the Token starts ("ey") until the part where it ends ("&token_type").

    Now we got the Access Token and can use it within the value part of the AJAX: Set request header.

  • Is there any possible way how I can reference a previous sprite if there are a multiple number of them?

    Like picking the sprite by it's IID: icon(icon.count-1)?

    I make a calendar. At every day in the calendar events can happen. If there is an event at a given day I will spawn an icon/sprite inside that calendar cell.

    Now I want to modify the size and position of the previous icon, if there is already an event at the same day. Instead of centering a single big icon I want to make both icons smaller and have one left and one right.

    Here is a screenshot from the event:

    And here is the result:

    As you can see the first icon is bigger and centered. That's how it should look like if there is only one event on that day. But because there are two events on that day both should be small and on the sides like the smaller, right one.

    But I do not know how I can edit the properties of the previous sprite from within the second subevent.

    I know some Javascript, but with runtime.Objects.RaidIcons(runtime.Objects.RaidIcons.count-1).destroy() I wasnt able to destroy the Icon with the previous Index.

    Any ideas? Thanks in advance! :D

  • Oh nevermind. You are right. I had this piece of script at a wrong place.

    Thank you for your quick help. Very appreciated. :)

    Do you know how I could use this to read the access token of an url? I'm currently trying to do it with substring, slice and so on but I'm a novice in javascript. Maybe there is an easier way. :D

  • Hello!

    Is there a way to read the current url the project/game is running on?

    Because when I can read the url I can try to extract the access/login token from the url.

    I tried this property to read the url:

    window.location.href;

    But no success so far. window.location.href should return the current url, right? When I insert this to the browser debug console it displays the correct url. But when I set a global variable to this via script the variable remains blank.

    Thank you in advance! :)

  • You do not have permission to view this post

  • Wow super awesome! I was exactly looking for something like this. Thank you very much. :)

  • It is planned for the use as an UI element. And I do not know the radius yet. So I would really love if someone could have an example on how to use drawingcanvas eventing or javascript.

    I found things like

    function roundRect(x, y, w, h, radius) { var canvas = document.getElementById("canvas6"); var context = canvas.getContext("2d"); var r = x + w; var b = y + h; context.beginPath(); context.strokeStyle="green"; context.lineWidth="4"; context.moveTo(x+radius, y); context.lineTo(r-radius, y); context.quadraticCurveTo(r, y, r, y+radius); context.lineTo(r, y+h-radius); context.quadraticCurveTo(r, b, r-radius, b); context.lineTo(x+radius, b); context.quadraticCurveTo(x, b, x, b-radius); context.lineTo(x, y+radius); context.quadraticCurveTo(x, y, x+radius, y); context.stroke(); }

    in the Javascript documentation. But many times when I try to use plain Javascript I get errors when testing the game.

    When I use this with roundRect(700, 600, 200, 200, 10) I get "Cannot read property 'getContext' of null".

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Thank you for the reply. I already saw the post. Does it mean I need to draw the 9 patches as a sprite and set it up in a complicated way?

    I would have liked to avoid this, as I hate spriting and I would prefer code. :D

  • Hello!

    How do I draw a rounded rectangle?

    Either with events or scripts will work for me.

    I tried it with scripts but many times things will not work if I try using the normal javascript syntax.

    Thank you in advance. :)

  • I noticed that everythime that I start the preview of the project the pop-up window will be a little bit smaller than before. After several time I will need to resize the preview window manually because it got too small. I use google chrome.

    Is that a browser thing or a bug?

  • Oh thank you very much. That makes sense. I fixed it now by using sprites.

  • Hello together.

    Currently I'm doing a calendar with construct 3. Therefore I have a number of buttons (the date cells) and want the date number to be in the top left corner of the button.

    I do not use normal button text, because each button (date cell) will have several numbers and text all over this cell (date number, text, etc).

    But whatever I do with Z ordering the text object it always keeps behind the buttons. Is there a behaviour like the buttons are always on top of all other objects no matter what, or am I doing something wrong?

    On start of layout I create the buttons with a nested loop. I tried several Z order things with the text.

    But the text keeps being behind the buttons. I deleted a cell, so you can see where the text is.

    What can I do to have the text above anything else?

Nilom's avatar

Nilom

Member since 26 Dec, 2019

Twitter
Nilom has 1 followers

Trophy Case

  • 4-Year Club
  • Forum Contributor Made 100 posts in the forums
  • Regular Visitor Visited Construct.net 7 days in a row
  • RTFM Read the fabulous manual
  • x2
    Great Comment One of your comments gets 3 upvotes
  • Email Verified

Progress

9/44
How to earn trophies