lijenx's Forum Posts

  • 10 posts
  • justifun Perfect! Thanks for your help.

  • When two sprites overlap and I click with the mouse in the overlapping area, both sprites receive a click event. As it is now I sometimes get click events for sprites that I cannot even see because they are completely obscured behind another sprite.

    How can I make it so that only the top-most (or front most) sprite gets a click event?

  • Rex Thank you! I get it now -- and it works great.

  • Rex, I appreciate your answer, but the code you linked didn't really clarify the issue. It looks like the mapping is created during this function call:

    cr.plugins_.Rex_Nickname.AddNickname = function(nickname, objtype)
    {
        cr.plugins_.Rex_Nickname.nickname2objtype[nickname] = {sid:objtype.sid, index:-1};
        cr.plugins_.Rex_Nickname.sid2nickname[objtype.sid.toString()] = nickname;
    };[/code:38jvi0km]
    
    But I think this leaves me with the same problem I asked about in the OP. See, I don't know how to get a reference a specific objtype. Or to be more precise, I can get references to lots of object types, but I don't know how to tell them apart. I don't know which one is "cardBackground" and which one is "cardText".
    
    When you say "user need to link the string name and the object type by action", do you mean the user playing the game?
  • I'm writing a plugin that creates new instances of objects that exist in the layout.

    The SDK Runtime reference has this to say about runtime.createInstance:

    [quote:1v5c1z11]runtime.createInstance(type, layer)

    Create a new instance of the object type on the given layer. Returns a reference to the created instance.

    After some searching the source (and a bit of trial-end-error) I was able to find a way get a reference to a type by its name:

        function createObject(typeName,x,y) {
            var type = null;
            for( var i=0; i<runtime.types_by_index.length; ++i ) {
                if( runtime.types_by_index[i].name === typeName ) {
                    type = runtime.types_by_index[i];
                }
            }
            var layer = runtime.getLayerByName("game-elements");
            var object = runtime.createInstance(type,layer);
            return object;
        };
    [/code:1v5c1z11]
    
    This code works just fine in the development environment. I pass the [b]typeName[/b] of the object, like "cardBackground" or "playButton" and voila, new instances. However, when I export the project to an HTML5 website this code no longer works. This is because the [b]name[/b]s of the types appear to have been transformed. The new names are strings like "t0" or "t1".
    
    So what is the best way to locate an object instance (or perhaps an instance-type) to use when calling runtime.createInstance?
  • I think I've answered my own question. I found the manual page for Saving, sharing and collaborating () and the tutorial for How to collaborate on projects with SVN ().

  • What would be some good options for sharing a project with multiple developers? It appears that the CAPX file is a monolithic binary project file. Not exactly friendly for svn/git diff/merge/patch. Is it possible to have multiple CAPX files as building blocks for a single game, for example each one having a different layout and event sheet?

  • 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
  • Gumshoe: no, there is no text property, nor color, nor font, etc.

  • 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?
  • 10 posts