bladedpenguin's Forum Posts

  • Thanks! I was able to resolve the issue with the JSON being "". Have a look at that demo I posted: it has the same issue as my main game.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • I'm working on a behavior that is able to save Objects and restore them later on. I figured out how to save the object's sid and look it up later to get the object type for creating it, but when I try to "set from JSON" on a new layer, the object gets destroyed. I am reading the JSON that I get from asJSON, and it looks like the issue might be related to the layer SID that is stored.

    I was wondering if there is a way to call the asJSON Expression from the SDK, and then later restore it in a way analogous to the "set from JSON" Action?

  • I was looking through the source hoping that perhaps the layer SID was causing the problem, but that doesn't seem to be the case. Can I partially set from JSON? If I remove a few elements from the JSON, can I still load from JSON and keep the other values as they are when the Item is created? I also noticed that the issue is independant of whether layouts are changed.

    Should I give up and go to some kind of abstract Inventory system? I'm hesitant to do that, since Construct 2 doesn't really handle abstract objects very well: You can't put them in data structures. It seems much more complicated to hang custom events on an array inventory....

    Edit: here is the JSON, after the "l" element was removed.

    {"c2":true,"ivs":{"4983201361434822":"2d12"},"w":{"x":40,"y":214.20833333333331,"w":24,"h":24,"zi":16},"behs":{"2355029582157182":{"SlotUID":611},"3459439661079695":{"enabled":true},"8791895563351892":{"dx":0,"dy":0,"cancelStep":0,"enabled":true,"stepMode":0,"pxPerStep":5}},"data":{"a":9827539049161972,"f":12,"cas":0,"fs":0,"ar":0,"at":0}}[/code:3991b27o]
    
    More Edit: Using firebug, I was able to catch [code:3991b27o]SyntaxError: JSON.parse: unexpected end of data at line 1 column 1 of the JSON data
    http://localhost:50000/commonace.js
    Line 609[/code:3991b27o] I'm going to look into why this instance is being passed an empty string. I've attached a screenie of the test event I created. I'd be inclined to leave a capx, but I am using a bunch of 3rd party behaviors.
    
    In this screenshot, Save Item and Create Instance are both functions from a little custom behavior I made which is able to save the object type of an unknown sprite, and respawn it from sid. It seems to work correctly. If I remove the Set From JSON line, it seems to properly creates a MeleeWeapon or FryingPan or Boots or whatever. I can upload that behavior if someone is interested.
    
    Edit: caught a major derp in the above screenshot. ItemJSON is now properly set to Item.asJSON, and everything works, at least in this test case without changing layouts. This is the same as my test case. I notice that it does NOT work if I strip out the layer sid, so that must be important somehow. It's also the only data in that JSON that seems like it might be mismatched.  Should I create a JSON mangler to replace the layer sid with the sid of the new "UI" layer?
    
    To confirm: I have my main project behaving the same way as this demo, which is able to save and restore sprites from JSON, but it just destroys the sprite whenever I try to SetFromJSON on a different layout from the one where the JSON was created. Help!
  • I can't seem to find it right now, but I think there was a forum post about how Airscape: The Fall of Gravity was done somewhere on the forums. You wouldn't want a constant "down"ward force like Airscape though, you would probably want the "gravity" force to be proportional to speed.

  • https://www.scirra.com/manual/150/containers

    One of the things containers allow you to do is to pick all items in the same container. When thing 2 gets picked by the collision, the associated thing1 and bluething get picked also, so you can activate collisions on thing1, and only the thing1 associated with the thing2 that got hit will activate.

  • An interesting problem.... My instinct is to take the magnitude of the cross product of the player's velocity and the surface normal and apply it reverse of the surface normal.... but I have no idea how to get that surface normal from a sprite.

    Edit: Maybe do something like Airscape, where you use overlapping invisible sprites to define the surface normal, and lerp when overlapping multiple sprites.

  • I am trying to let a player keep their items across layouts. I don't want to set the items global, because most items need to persist on their own layout.

    I noticed that when an object is SetFromJSON on a different layout, it disappears. Is there a way I can prevent this from happening? Is there a line I can delete from the JSON that will allow it to remain on the current layout? I'm pretty familiar with regexes, but the JSON seems to be obfuscated.

  • I'm not quite sure what you want to do, but I have some idea. Can you fix it with an else statement?

    I think the best solution is to use the System.TriggerOnceWhileTrue condition, which means that each object will only try and change the other when it is first activated. Then Maybe some kind of cooldown timer, depending on what you want to do.

  • Here we go. You were using System.CreateObject action, which means you have to get the coordinates of the imagepoint from expressions. I implemented this. Earlier I recommended Sprite.SpawnAnotherObject, and i implemented that too on Event sheet 1 so you could see it.

    I would recommend putting lots of your events on one event sheet, then including that event sheet in other event sheets. It saves you from having to duplicate work every time you make a new level

  • At some point somebody should make a plugin that implements bubble sort, if RexRainbow's plugin doesn't already....

  • Post your Capx so we can see what you are doing. If you are using sprite.spawnAnotherObject, there is a place for you to enter the image point that you want to spawn from.

  • There doesn't seem to be a way to stretch. I can't imagine it would look good to have everything all stretched out of shape anyway.

  • I'm also curious about how you manage picking in this situation....

    Since the towers don't move, you can set their Z order once at their creation or at the start of the level. Because you don't do it too often, you can afford to use an ordered ForEach to loop over them all by z order and send them to the top, one by one. This is, of course, the most horrible sorting algorithm ever, but I figure it's better than no solution at all.

  • I've been using the Anchor behavior to keep UI elements in thier proper place. It keeps UI elements in the same place relative to the edges of the screen, even though the UI layer doesn't always start at 0,0 in the inner letterbox modes.

  • Another solution would be to story previous X and Y as instance variables, and then on release, you use the difference between previous xy and current xy to get your Velocity. This and dt gets you the speed AT the moment of release. Theres also a couple different ways to average over the last few frames before release.