Whyser's Forum Posts

  • 12 posts
  • Okay thank you, then I know!

  • In your example all the instances (Sprites) are of a different "Object type" (A, B and C). My scenario is that I have one Object type: "Sprite1" and clone this, but assign different Nicknames.

  • I'm having problems using this. Not sure if I might be using it the wrong way!

    I create a new Sprite (Sprite1).

    Add the behaviour "Nickname".

    Copy the object (now having 2 instances of it in the layout, both with the "Name" of "Sprite1").

    The first one i "Nickname": "button_1" and the second: "button_2".

    Then i select the action: "Pick matched instances" and enter "button_1" as the nickname to be matched.

    Then i select the action to set visibility of "Sprite1" to invisible.

    Run the preview.

    Both of them are invisible.

    Is this intended behaviour?

    Thank you, rexrainbow

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • If you know you need a new line in your text, you could use the built-in newline object:

    "Hello" & newline & "World!"

    This would take a little more thought if you are creating the string on the fly.

    I'm asking how to do it using the method I mentioned since I'm creating a plugin.

  • (Sorry about double post, if a mod could merge my other post that would be great!)

    Is it possible to pass some "special-character" to create a new line for the EditTime method: font.DrawText? I know that "\n" doesn't work, and neither does anything else I've tried. Anyone know if this is possible?

    I wanna do this for example:

    this.font.DrawText("Hello \n World",
    								this.instance.GetBoundingQuad(),
    								this.properties["Color"],
    								halign,
    								this.instance.GetOpacity(),
    								this.instance.GetAngle(),
    								(this.properties["Wrapping"] === "Word"),
    								this.properties["Line height"],
    								valign);[/code:2v2sf4ih]
    Wanted output:
    [code:2v2sf4ih]Hello
    World[/code:2v2sf4ih]
    Received output:
    [code:2v2sf4ih]Hello [?] World[/code:2v2sf4ih]
    
    EDIT:
    I already know that I can create a new line by writing: & newline &, this is NOT what I'm after. I want to be able to do newline in edit-time, in other words, render a new-line inside the editor (not by pressing F5). 
    
    @Ashley mind answering if this is even possible? It all comes down to how the font.DrawText is implemented.
  • Oh, wow, cool man Good luck.

    May I know what is the plug-in are you working on?

    Nothing fancy really, just a plugin based on the Text-object so that one is able to use "\n" to create new lines and preview them inside Construct (not F5). Currently if you type default text into the Text-field of the Text-object it's impossible to get new lines.

    Would be best if this is either reposted or moved (hail a mod) to the Work in Progress Addons section.

    It would stand a much better chance of attracting the type of help you require.

    Ahh thank you for pointing that out! I'm quite new to this forum so wasn't sure where to post this question. So...Any mod wanna move this?

  • Thanks, but that's not what I'm after. I'm writing a Plugin and need to be able to create a new-line using the "font.DrawText(...)" method (in edittime.js). As I can't see how the DrawText(...) is implemented under the hood, I can't find out how to accomplish this.

    Ashley is probably the only one who can answer this, or someone that asked him and got the answer.

  • Is it possible to pass some "special-character" to create a new line for the EditTime method: font.DrawText? I know that "\n" doesn't work, and neither does anything else I've tried. Anyone know if this is possible?

    I wanna do this for example:

    this.font.DrawText("Hello \n World",
    								this.instance.GetBoundingQuad(),
    								this.properties["Color"],
    								halign,
    								this.instance.GetOpacity(),
    								this.instance.GetAngle(),
    								(this.properties["Wrapping"] === "Word"),
    								this.properties["Line height"],
    								valign);[/code:1y6cwgtt]
    Wanted output:
    [code:1y6cwgtt]Hello
    World[/code:1y6cwgtt]
    Received output:
    [code:1y6cwgtt]Hello [?] World[/code:1y6cwgtt]
    
    Thank you!
  • Problem Description

    The problem is with the AJAX-plugin. It seems calling "setRequestHeader" to change the "Content-Type" of the request doesn't work. It uses the default value of: "application/x-www-form-urlencoded" even if you change it to something else.

    When looking at the code in the Plugin it does indeed seems like it should work, I even printed the headers and it seemed correct.

    Steps to Reproduce Bug

    • Add AJAX object to Layout
    • In: On Layout Start, set the header: "Content-Type" to Value: "application/json"
    • Make an AJAX request to some server
    • Observe on the server that the Content-Type that is being sent is "application/x-www-form-urlencoded".

    Observed Result

    As seen above, the request header is overridden by the default one (or not being set at all)

    Expected Result

    "Content-Type" should be set to "application/json", but isn't.

    Solution

    Removing the following lines in the runtime.js of the AJAX -plugin (line 218-224), seem to fix this problem:

    if (data_)
    {
      if (request["setRequestHeader"])
      {
        request["setRequestHeader"]("Content-Type", "application/x-www-form-urlencoded");
      }
    }[/code:fsszne24]
    
    [b]Construct 2 Version ID[/b]
    Release 190 (64-bit)
  • Yann

    I agree with you kinda, but I think it might depend on the use-case! My scenario is that I create those fields only to call "AsJSON(0)" directly after in an AJAX call, so that i can send JSON-formatted data to a server.

    Doing what you suggested (Load JSON) is very error prone and messy! If that's what i wanted to do, I would just write the JSON-object-string myself.

  • Thank you Yann for your response! I agree about your reasoning, but I think the benefits might overweight the losses. For a complex JSON-object where we have to go down even more hierarchy's it quickly gets messy and probably even more error prone when doing it in Construct.

    As a side-note, I actually tested what you described (created new object at every "level"), and had it worked I wouldn't have even bothered to look for this "bug". But I will try again and see if I maybe made some error the first time. Will get back to you! EDIT: It seems I had missed that there were an Action called "New Object" which was necessary for it to work as intended (which however isn't necessary when creating first-level objects).

    This is a lot more code (and probably more error prone as more objects gets added)

    Clear root@
    Set New Object at root@   // so the clear isn't necessary
    Set "Hello World" at root@"someText"
    Set New Object at root@"location"
    Set New Object at root@"location","latitude"
    Set New Object at root@"location","latitude","someCoordObject"
    Set 100 at root@"location","latitude","someCoordObject","Coord1"
    Set 110 at root@"location","latitude","someCoordObject","Coord2"
    Set 120 at root@"location","latitude","someCoordObject","Coord3"[/code:33o8mxuh]
    
    Then this:
    [code:33o8mxuh]Clear root@
    Set New Object at root@   // so the clear isn't necessary
    Set "Hello World" at root@"someText"
    Set 100 at root@"location","latitude","someCoordObject","Coord1"
    Set 110 at root@"location","latitude","someCoordObject","Coord2"
    Set 120 at root@"location","latitude","someCoordObject","Coord3"[/code:33o8mxuh]
    
    Imagine when we have multiple objects that have multiple hierarchy's the actions required will expontential (figure of speech )!
  • I think I found a bug.

    It seems it's not possible to do the following:

    clear root@

    set "Hello World" at root@"someText"

    set 10 at root@"location","latitude"

    set 20 at root@"location","longitude"

    This will cause a warning and the JSON object will be {"someText":"Hello World"}. After a long time of reading your plugin I think I found the error (or at least a fix for my problem). In the method on Line 208: "instanceProto.setValueFromPath".

    Change this:

    if(i < path_.length-1) {
    	obj = obj[path_[i]];
    } else {
    	obj[path_[i]] = value; // silently create a new property if doesn't exist yet
    }[/code:1j5vqyqm]
    
    To this:
    [code:1j5vqyqm]if(i < path_.length-1) {
    	if(!(path_[i] in obj))
    		obj[path_[i]] = {};
    
    	obj = obj[path_[i]];
    } else {
    	obj[path_[i]] = value; // silently create a new property if doesn't exist yet
    }[/code:1j5vqyqm]
  • 12 posts