brendanpoke's Forum Posts

  • I'm trying to create json files with all the information of my layouts and create others automatically.

    I have to acquire all the data regarding the variables of all the sprites, now I have this problem:

    If I do: console.log(Sprite.InstVars) I get an output (like in the screenshots).

    But I can't get the variables any other way.

    if I do:

    Sprite.LocalVars.variablename

    I get that variable, but I want to use .localvars because I need to get all

    and how many there are.

  • could you also tell me how to insert the variables into JSON format?

    How can I do the same thing with the JSON plugin?

    JSON --> set value --> Set "."&loopindex&".height" to int(FamilyALL.height) what is written above in my screenshot, how can I do it with the script?

    I should get in the console:

    "Level_1": {

    "Sprite": [ { "posx": 20291, "posy": 223, "size": 50609, [{ ---> ObjVar1: 999, <--- ---> ObjVar2: zzz, <--- ],}

    }

    ],

    I'm also fine with doing everything with the script, but for each of my objects in the layout I need to have all the information regarding it

  • > I tried to use your code but it gives me an error on key<> and I don't understand why.

    Sorry, I don't use JS often, it should be != instead of <>

    I assumed you know Javascript since you asked for a script solution?

    Here is a demo.

    https://www.dropbox.com/scl/fi/iw8pscxnqot8t6dnx0965/JS_InstVars.c3p?rlkey=nrdw9bcn9s4yn0k61jc6ra03d&dl=0

    Yes I'm studying javascript step by step. but I'm still at the beginning.

    Thank you so much!

    I also inserted a new sprite and got the variables of all using getFirstPickedInstance:

  • > I didn't understand how to use the first one.

    It's easy. Save Sprite.AsJSON to a text variable. Later, when you need to restore, create a new Sprite instance and use "Sprite Set From JSON" action - it will restore its position, instance variables and all other properties from the saved JSON.

    > I would like the console.log to also write the object variables not related to the family.

    You know which variables are related to the family - simply exclude/ignore them when running the "for (var key in o.instVars)" loop.

    > for (var key in o.instVars) {
    
    if (key<>"FamVar1" && key<>"FamVar2") {
    console.log(key + ": " + o.instVars[key]);
    }
    }
    
    

    Sorry, I can't understand, could you give me a practical example?

    I tried to use your code but it gives me an error on key<> and I don't understand why.

    Could you make a sample project and post screenshots?

    Thank you.

  • to show the range to the player you can create a "circle" object and increase its size for towers with longer range.

    To define when the towers can start shooting you can use distance.

  • I was looking for a solution and discovered this thread.

    I have the same problem and I can't go and add the layer to those 500 layouts every time.

    Has a feature been added for this issue?

    construct.net/en/forum/construct-3/how-do-i-8/replicate-new-global-layer-149322

  • If you need this to save/restore sprites on the layout, you can use Family.AsJSON expression. It will save all object properties, including the values of all instance variables. However, there will be unique codes instead of variable names.

    Or you can retrieve all instance variables with this script:

    > const o = runtime.objects.Family.getFirstInstance();
    
    for (var key in o.instVars) {
    console.log(key + ": " + o.instVars[key]);
    }
    
    

    I tried the second method (the script), because I didn't understand how to use the first one.

    That's not what I meant anyway.

    I would like the console.log to also write the object variables not related to the family.

    I put up some screenshots.

    I also modified some variables in the layout view of the objects (related to the family) but in the console the 4 variables are always 0 and "" and false. (probably because it's not correct how I made the events and how I included your script. I don't know how to do.)

    Sorry for the strange names, but I'm Italian and I program half Italian and half English.

  • I'm trying to write all the information of the sprites contained in my layouts with JSON.

    Including size, angle and even instance variables.

    But I do this by using a family that contains all the objects.

    Previously I had inserted objects in the layouts that have specific variables, for example:

    (items to collect):

    grenades (variable "ammo" and variable "damage".

    (enemies) :

    ufo ( variable "lifepoints" and variable "attackpoints" .

    These variables are specific to each type object.

    Is there a way to access it using scripting?

    I want JSON to also write all the variables and values ​​for each type object that is part of the family.

  • You know, that makes a lot of sense.

    Right?! Why would you still pay for C3 if you have to learn JS anyways? Very observant, with a simple and logical conclusion.

    I wonder if more people think that way?

    I think so too, but I have to say something else:

    When I started programming (4-5 years ago with Construct3) I did so because I had no idea where to start with javascript, (I didn't even know what it was), instead I knew something but little about html.

    But not knowing where to start, I looked for html guides (and the complexity scared me).

    In short, not knowing how to do it, I found Constrcuct3 by chance and I started with that, thinking: maybe if I start from something simpler I will be able to learn the code in the future.

    and that's exactly what happened. Construct3 helped me and made me learn a lot, and it's thanks to it that now I can understand javascript code, html etc... also because I trained my mind, memory and logic. even I don't use code. So it was a go-between and I'm glad I started that way.

  • It's entirely up to you which you use. If you're experienced with both, event sheets and JavaScript code still have their own strengths and weaknesses. For example in my Command & Construct game project, I mostly used JavaScript coding, but I still used event sheets for the menu systems, because it's quicker and easier than having to write code for a menu system.

    honestly I want to do the hardest thing and that allows me to do more. That's why I thought that javascript (at least I think) is the basis of Construct3, i.e. if so, maybe with javascript I could create a program identical to Construct3?

    Perhaps it would take too much work time considering that Construct3 was made by a team maybe years of work.

    But the point is that javascript is at the core, so learning that (even if it takes a long time) when I've learned it I'll be able to do everything I did with Constrcut3 anyway. And maybe much more and faster.

    You talked about strengths and weaknesses, what are the weaknesses of javascript?

    I'm following a video tutorial course for javascript (and also html and css), and it seems to me that in terms of organization, variability of elements, it's more efficient.

    with javascript can I do everything I do with Construct3? Like making a spaceship that moves etc...? My games are Anime style, I like to put artistic images and it's animated, but I'm not interested in big special effects like 3D.

    If you want I can put the link of a free video game that I made and published on the play store, to give you an idea of ​​how I want the style of my games to be, even if my game is still incomplete and scarce in terms of content (not to mention of so many bugs there are).

  • Lately I've been wondering, since I've learned to do more and more complex things in Construct3, and I want to make complete and long-to-finish games, like a real game such as pokèmon etc...,

    If it's convenient, if it's better to learn javascript code in a complete way and program my games only with the code (if it's possible).

    Since I have so much work to do, and I want to improve and become faster, I have to figure out how to save time and optimize my work. Could I do the same things I do with construct3 with just my code? Consider that for example "behaviors" or effects I've never used in Construct3, because they limit what I can do even if they are faster.

    I generally always prefer to do everything starting from 0 for several reasons.

    If learning javascript well was a good idea, even if I have to study more, I would.

    What do you recommend?

  • Thank you!

    I haven't tried it yet. but it seems to me the perfect solution to use "drawing canvas", also because the brown circles could be in "destination over" mode and show the underlying layer, ie the wall of the planet.

  • Hi everyone.

    In my game there is a planet with tunnels (many in proportion to the size of the planet).

    But they must all have the same thickness, scaling the image happens like in the screenshot at left, is there any way to avoid this?

    Tagged:

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • I didn't know about this feature yet. Thank you :)

  • I would do like this, example: