text object problem

0 favourites
  • 13 posts
From the Asset Store
OpenAI TTS
$10 USD
Text-to-Speech plugin.Allows your Construct 3 project to convert written text into spoken words
  • okay so I press enter to make paragraph 1 appear, using "set text". I want to press enter again to change the text to paragrpah 2, however it doesn't erase paragrpah 1, rather paragraph 2 appears OVERTOP of it. how do I fix this?

    capx: http://biancagames.com/textbug.capx

    screenshot:

  • DialgaBrite, one thing to take note of is that you can re-use a Text object to display text and you don't need to keep creating the Sprite. So I removed the repeated creation of your Sprite and Text object and put the Text on Layer1 and the Sprite on Layer0. The layers were arranged in the layers tab so that the Text would be displayed on top of the Sprite. The order from bottom to top in the layers list indicates the order of rendering the Objects on each layer. In addition, since you didn't want the Sprite or Text object showing at first, I set the Initial Visibility in the Editor to Invisible for both of them. To support the triggering of making the Sprite and Text Object visible, I added a global variable that was initially set to 0 but then later set to 1 to indicate that the Sprite and Text objects were made visible. I knew that the first message was to be set first so that's where I put the Sub-Event for making the Sprite and Text objects visible. Now just like with visibility, we use that 'paragraph' instance variable on the Text object so that when it is 0 and Return is pressed we set the text to the first message and Add 1 to the 'paragraph' instance variable. 'paragraph' being 1 indicates to us that the first message has been set and that the next time Return is pressed that the text should set to the second message. So we have that additional event that is checking for when 'paragraph' is 1. Now in order to alternate we have to have the second message event subtract 1 from 'paragraph' so that we go back the initial state of waiting to set the text to the first message.

  • DialgaBrite, one thing to take note of is that you can re-use a Text object to display text and you don't need to keep creating the Sprite. So I removed the repeated creation of your Sprite and Text object and put the Text on Layer1 and the Sprite on Layer0. The layers were arranged in the layers tab so that the Text would be displayed on top of the Sprite. The order from bottom to top in the layers list indicates the order of rendering the Objects on each layer. In addition, since you didn't want the Sprite or Text object showing at first, I set the Initial Visibility in the Editor to Invisible for both of them. To support the triggering of making the Sprite and Text Object visible, I added a global variable that was initially set to 0 but then later set to 1 to indicate that the Sprite and Text objects were made visible. I knew that the first message was to be set first so that's where I put the Sub-Event for making the Sprite and Text objects visible. Now just like with visibility, we use that 'paragraph' instance variable on the Text object so that when it is 0 and Return is pressed we set the text to the first message and Add 1 to the 'paragraph' instance variable. 'paragraph' being 1 indicates to us that the first message has been set and that the next time Return is pressed that the text should set to the second message. So we have that additional event that is checking for when 'paragraph' is 1. Now in order to alternate we have to have the second message event subtract 1 from 'paragraph' so that we go back the initial state of waiting to set the text to the first message.

    You really lost me there, but I suppose I will download it. I think putting the box on a different layer is uneccessary. And why do we need a global value to tell if it's visible if we can just make it visible?

    edit: your edit fixes the problem, but can you PLEASE explain why much more simply?

    also why are we subtracting 1 from the paragraph value? won't we need to only add to it if there are 3 or more paragraphs?

  • You don't need a global variable to check for visibility !

    From the manual :

    Is visible

    True if the object is currently visible. Invert to test if invisible. This only tests the visibility set by the Set visible action; it is not affected by the object being offscreen, having 0 opacity, or being on an invisible layer.

  • http://biancagames.com/textbug3.capx

    this one is almost identical to the first, but it doesn't produce the problem. what gives? I really would like to understand what you did, I took out the use of another layer as well as having a global value for "has pressed return", and also the "subtract 1 from paragraph". those clearly had nothing to do with it and were completely uneccessary. I also have no idea why you wanted to subtract when normally there will be more than two paragraphs and we will want to add.

    edit: added back in the "set to bottom of layer" every tick. that's not the problem either. Why did you change so much stuff unneccessarily?

    edit 2: the problem was creating the objects in the same event where I show paragraph 1. why?

  • You're right I was just trying to quickly fix DialgaBrite .capx and explain it. DialgaBrite, I didn't know that you were going to have multiple paragraphs. But if that is the case then yes you don't need the 'subtract 1 from paragraph'. As to why there was a problem creating objects every time, I'm not sure. I'd have to look back at your original .capx and look again. Sorry if I caused more confusion than help.

  • You're right I was just trying to quickly fix DialgaBrite .capx and explain it. DialgaBrite, I didn't know that you were going to have multiple paragraphs. But if that is the case then yes you don't need the 'subtract 1 from paragraph'. As to why there was a problem creating objects every time, I'm not sure. I'd have to look back at your original .capx and look again. Sorry if I caused more confusion than help.

    I found the problem. It's creating the objects in the same event as where paragraph 1 is set. You fixed it by creating them at start of layout instead. I am still wondering though why this made a difference. Sorry if I seemed rude btw. I just thought a lot of your other changes were unneccessary.

  • Yes. Quite a few of the changes were un-necessary and very badly done. Oh I just thought of why the one problem was persisting due to repeated object creation. The first message 'paragraph 1' is being drawn on top of message 'paragraph 2! more text here!'. And that's because the Red Box Sprite is always drawn first on the bottom layer, because that's the layer you had it originally set to through that 'Every tick' Event. So the Red Box Sprite never get's drawn over the Text objects to provide a surface if you will on which to render a new Text object. But the Text Objects get drawn over each whenever they are created. So that's how you see the text of the longer message.

  • Yes. Quite a few of the changes were un-necessary and very badly done. Oh I just thought of why the one problem was persisting due to repeated object creation. The first message 'paragraph 1' is being drawn on top of message 'paragraph 2! more text here!'. And that's because the Red Box Sprite is always drawn first on the bottom layer, because that's the layer you had it originally set to through that 'Every tick' Event. So the Red Box Sprite never get's drawn over the Text objects to provide a surface if you will on which to render a new Text object. But the Text Objects get drawn over each whenever they are created. So that's how you see the text of the longer message.

    Sorry, but I really didn't understand what you just said. The every tick action moves it to Z-order bottom of the same layer, not a different layer.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Oh sorry you're right. There is a z-order on every layer sorry about that. I haven't been using Construct 2 for very long so I mix z-order and layers up pretty frequently. Anyways on that layer the Red Box Sprite is always drawn first then you have the a Text objects drawn over the top. However you keep having Text objects drawn on top of each other, so if one has longer text than the other then you'll see it. Like in the case of your 'paragraph 2' message it's longer so when you have the Text object that has the 'paragraph 1' text created it is drawn on top only covering a portion of the 'paragraph 2' message below it.

  • Oh sorry you're right. There is a z-order on every layer sorry about that. I haven't been using Construct 2 for very long so I mix z-order and layers up pretty frequently. Anyways on that layer the Red Box Sprite is always drawn first then you have the a Text objects drawn over the top. However you keep having Text objects drawn on top of each other, so if one has longer text than the other then you'll see it. Like in the case of your 'paragraph 2' message it's longer so when you have the Text object that has the 'paragraph 1' text created it is drawn on top only covering a portion of the 'paragraph 2' message below it.

    What do you mean I keep having text objects being drawn? There should only be one, and even when the problem was there, there was only one. I still have no clue what you are talking about.

  • Referencing your first capx, before you press return there is one text2 object offscreen.

    When you press enter the first time another text2 object is created and 1 is added to it's paragraph variable. The first instance will still have a paragraph value of 0 since it wasn't picked when the add 1 action was run. It wasn't picked because when you create a text2 instance it becomes the only instance picked for the actions that follow.

    So now there are two instances of text2. One offscreen with a paragraph value of 0 and one on screen with a paragraph value of 1. Now after that when you press return a second time both of your events will run because one instance has a paragraph value of 0 and one has the value of 1.

    You could just move the text2 object instead of creating another and set it up like this:

    https://dl.dropboxusercontent.com/u/542 ... fixed.capx

    or this:

    https://dl.dropboxusercontent.com/u/542 ... ixed2.capx

    On a side note take a look at the 9patch object. With it you can reproduce the bigredtextbox object exactly using a much smaller image.

  • Referencing your first capx, before you press return there is one text2 object offscreen.

    When you press enter the first time another text2 object is created and 1 is added to it's paragraph variable. The first instance will still have a paragraph value of 0 since it wasn't picked when the add 1 action was run. It wasn't picked because when you create a text2 instance it becomes the only instance picked for the actions that follow.

    So now there are two instances of text2. One offscreen with a paragraph value of 0 and one on screen with a paragraph value of 1. Now after that when you press return a second time both of your events will run because one instance has a paragraph value of 0 and one has the value of 1.

    You could just move the text2 object instead of creating another and set it up like this:

    https://dl.dropboxusercontent.com/u/542 ... fixed.capx

    or this:

    https://dl.dropboxusercontent.com/u/542 ... ixed2.capx

    On a side note take a look at the 9patch object. With it you can reproduce the bigredtextbox object exactly using a much smaller image.

    that makes sense, thanks for explaining! <img src="{SMILIES_PATH}/icon_e_smile.gif" alt=":)" title="Smile">

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)