How do I modify a Text object's Text property in my plugin?

0 favourites
  • 7 posts
From the Asset Store
Animated Text
$3.99 USD
With AnimatedText behavior you can make an impression of the text being “typed live”.
  • I'm working on a game that will have tiles with words on them. There are algorithms (plural) for the number and placement of the tiles. I have written a plugin that implements the first of the algorithms. It creates the objects and places them into the layout. Everything is good up to that point.

    The challenge I have is that I don't see how to set the Text property of a Text object from my JavaScript code. Here is my code that creates the object:

    function createObject( type, x, y ) {
      var layer = runtime.running_layout.layers[type.default_layerindex];
      var object = runtime.createInstance(type,layer);
      object.x = x;
      object.y = y;
      return object;
    }
    [/code:1z76hlya]
    
    The placement algorithm uses this function to put the text objects on the layout. Works like a charm. But the object does not have a Text property, so I cannot set the object text. In the debugger the object's constructor is shown as pluginProto.Instance and the text properties (Text, Font, Color, etc.) are not available.
    
    So how do I modify the Text-specific object properties?
    
    Also, is this kind of information in the documentation somewhere? I haven't been able to find a good reference for creating and manipulating objects from a plugin. Maybe I'm using the wrong search terms?
  • Is there a .text property?

  • Gumshoe: no, there is no text property, nor color, nor font, etc.

  • Most text-based JavaScript objects have a .text property.

    So, assuming your Object is a text-based object, you should just be able to do "object.text". Other than, that, idk.

  • try this tutorials you might find your answer here

    https://www.scirra.com/tutorials/1334/c ... onstruct-2

  • Gumshoe my mistake. I had a brain burp. I was looking at the wrong object in the debugger. You are right, the Text object has a text property accessible from the JavaScript plugin (and font property as well).

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Yea, I kind of figured, since I don't think there is any other way of accessing the object text.

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