oosyrag's Forum Posts

  • The problem does seem to be that you're pinning every tick. Basically every time the position updates, you're resetting the pin to the new location, not letting pin do it's job.

  • What? Pinned objects do move with the base object, that's the whole point.

    Perhaps you are confusing the advice not to use the pin behavior with physics?

  • Construct 2 didn't have a json plugin. I don't know about third party add ons and what they can do, I'm guessing they just didn't include the arraysize expression. Or it might be called something else, would need to check the documentation of the plugin.

    You can get a similar value and store it in a variable by using a "for each" at the path of the array, and add one to the variable in the for each event.

    If you're doing this in c2, I'd say just use an array, the array.asjson expression and load from json action. It's a little more cumbersome because you can't edit the project file directly in the editor in c2 either, but it should still work. I'll put together another example in c2 when I get a chance, it would double as an example for how to do this with arrays.

  • Yes, it's definitely possible.

    But third party servers and interfacing with them are generally beyond the average forum goers knowledge here. Best familiarize yourself with the documentation and work from that.

  • If a layer's Global property is enabled, then every layer in the project with the same name is overridden by that layer. The initial objects, as well as its properties, are used instead of the other layer's own content and properties. Then changes can be made once to the original global layer, and the changes will be applied project-wide

    Global

    By default, all instances are destroyed when the layout ends (e.g. when going to the next layout). If enabled, none of the instances of this object type will be destroyed when switching layouts.

    The two are distinct and not really related. The manual describes what each does pretty clearly. What are you trying to do?

    If you have a global object on a global layer, the object will not be destroyed upon leaving the layout, and because the layer is global there will be another copy created on the new layout that has its own copy of the global layer.

  • There is a background color setting in project properties.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Make an artificial border, within the bounds of the layout, that prevents the player object from approaching closer than half the viewport to the actual edge of the layout. Then the scroll to behavior will work fine as you described.

  • + Mouse: On any click
    + Object1: Is overlapping Object2
    -> Object2: Destroy
    

    If you mean two instances of the same object instead of two different objects, you can use the system 'pick nth instance' condition instead.

  • Also... Is your grass and tree generation event running every tick? That's going to cause problems.

  • For an infinite world, it is often preferred to move everything else around the player, instead of the player object itself.

    The player stays in the middle of the layout (which would be maybe 2-3 times the size of the viewport). The layout can contain what is active in your world (known as a reality bubble in some games). Things outside the layout can be destroyed and recreated when approached by generating it again from the seed.

    If the world is modifiable by the player, you would additionally need to keep track of the difference between default state and current state of objects, such as if a tree got chopped down.

  • Try this -

    The example has also been updated again (I hope!)

    Here I'm setting the item ID directly after creating the object (based on the number of entries in ".items" in the json file). Then, I loop through each ".items" in JSON to see which one matches the ID of the object I just created. If it matches, then set it to the animation to the ".animName" that is located in the same JSON entry that matches the ID.

    One alternate way you can work with JSON is that if the order of your objects in JSON is fixed, such that the index of the array matches the id of the object (Item ID 2 is at array index 2 of the ".items" array), you can look it up directly with a absolute path instead of a relative path. The path would be "items.2.animName". It's a string, so you can stick an expression in there with &.

    Item: Set animation to JSON.Get("items."&Item.ID&".animName") (play from beginning)
    

    If I were to do it this way in this case I would get rid of the "ID" key in the json completely, the index/position of the object becomes it's ID.

    Edit: I think a lot of your roadblocks are coming from the JSON object. It's a little less user friendly to work with than an array or dictionary. One of the biggest advantages of JSON it is that it can make it easy for end users mod your game if you keep data in an easily readable JSON file (or collaborators who are not familiar with construct/code in an open source project, for example). If you're the only one who is going to be working with it, it might make more sense to just use an array or dictionary directly. On the other hand, this kind of crafting system project is an excellent application of JSON, and a good way to learn how to use it.

  • I imagine drag drop for controller would just be enabling 8 direction on the object you are over while button is down. 8 direction for the cursor as well.

  • How are you spawning items randomly? When you spawn the item, you can look up what it is supposed to be from the json (or a dictionary or array list). Alternatively, you can just set the ID randomly first, then set the animation based on it's id instead (looking it up in the json again).

  • Here's a visualization of what happens during an array pushing, see if it helps. When you push, you only push on the x axis, the other axis gets filled by whatever you pushed.

    docs.google.com/spreadsheets/d/1muTLyfKFaxD5WykJ2YoKYfg_lRQeuuABC5HwNi2t670/edit

    NaN means "Not a Number", which is what you get when you try to combine a string (animation name) with a number (ID), and try to put it into a number variable.

    I'm not sure about what's wrong with setting your items from the array, but maybe try again when your array is how you want it.

  • For situations like this, I like to use an invisible helper sprite, a "spawner" that stays in the original position and keeps track of values like timing and position.

    The objects created from the spawner can have an instance variable "origin" or "source" that I like to set with the UID of the spawner on created, so that each instance knows where it was created from, and I can use that to pick the correct spawner when the object gets destroyed. This helps in situations where you might have to work with multiple spawner objects.