Fengist's Recent Forum Activity

  • Wow, but I see what you're saying.

    I have an on browser resize event that calls a function to handle the resizing. I also call that function on the start of any layout.

    I did some testing and put the ViewportLeft and ViewportWidth into a text box just before it called the function. Well into the function is where I resize one of the HTMLElements and I grabbed the ViewportLeft and Width again and put them in a different text box. If I slowly resized I was seeing maybe a 0.5 - 3px difference. But, if I did a quick drag and release resize, I was seeing 50-100px differences.

    If I clicked on the full-screen request button, the px differences were pretty huge, like 500px+

    Now, whether this is affecting that CSS div, I dunno.

  • Good guess but no difference. I even bumped it to a full second. The skillsbox according to the debug is staying at a 950px width. But, that CSS div that's getting inserted above it is changing based on the browser size. But only on the laptop. The desktop, the CSS stays at 950px.

    Damned befuddling.

  • Really? Ok, I'm off to experiment because that kinda makes sense. The machine where it works perfect is an 8 core 4ghz with 32gb ram. The other machine is just an old dual core laptop with 4 gigs.

    I'll let you know the result.

  • Yep, took your suggestion, made one catchall event and checked the tag. Worked great.

    But, as it turns out, that wasn't the cause of all the checks going on. It was JSON checks for keys. Unfortunately, there doesn't seem to be an onParsed event for JSON. So I'm checking every cycle to see if any of several keys exist which only exist when the Ajax gets a response and then, I have to delete the key to keep them from being true every cycle.

    Thanks again though.

  • Ok, that makes sense. I was trying to put an Ajax on event inside another ajax on event.

    Thanks.

  • Was watching my code in the debugger. I have several Ajax events that keep firing even when there's no Ajax request being sent. So, I thought I'd streamline things a bit and create an Ajax On Any Completed and then, move all of my Ajax On Completed events under it. That way, the code isn't constantly checking half a dozen events and is instead, checking just one.

    Well, I was surprised to find out that I can't make an Ajax event a sub event.

    So, I thought I'd be clever. I'd create a function and On Any Completed, I'd call the function to see which Ajax event completed. Wrong. Apparently you can't even make any Ajax event part of a function.

  • Still trying to figure this out. Here's some more details:

    Taking a look at the HTML in Chrome developer there is a 'div' for most every element. The div for the skillbox looks like this:

    <div sa-uid="53" id="" style="font-family: Arial; font-size: 12px; color: rgb(0, 0, 0); font-weight: normal; font-style: normal; text-align: center; border-radius: 0px; padding: 0px; overflow: hidden scroll; transform-origin: left top; opacity: 1; position: absolute; left: 460px; top: 393px; width: 950px; height: 376px; transform: rotate(0deg);">
    

    Of note is the width: 950px. On one machine, with the same construct code mind you, that width stays at 950. On another machine, that width changes based on how wide the browser is.

    So my question now is, what sets the CSS properties for this 'div' and why is it changing on one computer and not the other? Does the plugin set these CSS styles or does Construct?

    I've also checked, both computers are using the latest version of Chrome.

    Chrome warning note to self when I check other machine: [C3 preview] Browser opened wrong size popup: wanted 1600 x 900, got 1584 x 821; resizing to compensate.

  • I agree with AllanR. You're using local storage like a variable. It should be used for saving things that you want to remember when the user quits playing so that you have that info the next time the user starts the game. You should load them on start of layout and save them only when you need to. The rest of the time, just use a global or local variables.

  • I believe, Chrome mandates that a user press something before it goes full screen.

  • Ok, it's becoming apparent this is peculiar to the HTMLElement plugin but I can't understand why.

    Here's an image of both the SkillsBox and the SkillsInfo box selected in debug. The box sizes appear to be correct but apparently the contents are getting scaled down depending on the browser size.

    What I don't understand is why on one machine this scaling is taking place but not on another. Any ideas?

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • So, here's the issue. I have several elements on a layout. Whenever a layout loads or the browser gets resized, I run a function to position these elements based on the viewport variables.

    Aside from the fact that this gets damned confusing because depending on how you resize the browser the Viewport vars can actually go into the negatives, I'm having issues with different behaviors on different machines using the same save file.

    For example. On one machine, I can set the width of the element in the properties and it keeps that width regardless of the browser size. On the other machine, same save file mind you, when the browser width changes, the element's width changes.

    Same thing with position. I tell it to position an element based on another element's x position and width. On one machine, it's position stays where it should when I resize the browser. On another, it moves left and right depending on the browser size.

    Now I thought maybe this was because of resolution or some such. But I'm basing my location on fixed coordinates and not percentages.

    On one machine, this perfectly positions and scales the SkillsInfoBox based on the location of the SkillsBox and it perfectly resizes the SkillsInfoBox based on browser size.

    -> SkillsInfoBox: Set position to (SkillsBox.X+SkillsBox.Width , SkillsBox.Y)

    -> SkillsInfoBox: Set width to ViewportRight(0)-SkillsInfoBox.X-20

    On the other machine, in order to achieve the same effect, I have to do this:

    -> SkillsBox: Set width to SkillsBox.X+750

    -> SkillsInfoBox: Set position to (SkillsBox.X+980 , SkillsBox.Y)

    -> SkillsInfoBox: Set width to ViewportRight(0)+ViewportLeft(0)-SkillsInfoBox.X-20

    You'll note that these lines of code are quite different. On one, I can set positions and width based on the SkillsBox position and width and the Viewport vars. On the other, I have to manually set width's and I'm having to add in the ViewportLeft(0) in order to correctly calculate the element width.

    So I can only come up with 2 reasons why this would happen. Either the viewport calculations are vastly different on one machine than they are on the other (which doesn't explain why an element resizes on one machine and not the other) or some setting that I'm totally missing isn't getting saved in the save file.

    Here's a visual. The SkillsBox is on the left, the SkillsInfoBox is on the right with the red border (so I can see the x position and width better)

  • Create a text element and add a bullet behavior. Uncheck 'set angle' on the behavior.

    And, here's your code:

    + System: On start of layout

    -> Text: Set position to (ViewportRight(0)+1, 0)

    -> Text: Set Bullet speed to -150

    + System: Text.X+Text.Width+1 < ViewportLeft(0)

    -> Text: Set X to ViewportRight(0)+1

    This is a very, very basic 'ticker.' If your text is static, this will do the job. If your text changes, you're going to have to come up with your own way to set the width of the text box because that's how it decides when to reset back to the beginning.

Fengist's avatar

Fengist

Member since 6 Nov, 2015

Twitter
Fengist has 5 followers

Trophy Case

  • 9-Year Club
  • Forum Contributor Made 100 posts in the forums
  • Forum Patron Made 500 posts in the forums
  • x3
    Coach One of your tutorials has over 1,000 readers
  • x2
    Educator One of your tutorials has over 10,000 readers
  • Regular Visitor Visited Construct.net 7 days in a row
  • RTFM Read the fabulous manual
  • Email Verified

Progress

16/44
How to earn trophies