cacotigon's Recent Forum Activity

  • Back in the day, I would always make sure that a set of sprites in an animation had the same fixed dimensions. So if I had a run animation (for example) consisting of four sprites, I would set each sprite's canvas size to be equal to the size of the sprite in the animation with the largest size, which usually resulted in some transparent margins.

    Mostly I did this to make sure that when I was rendering the animation to screen, it ensured that the animation was fixed in place since the origin was usually top-left. It also made it easier to draw sprites via a source rectangle since I usually drew the sprites from a single sprite sheet at run-time.

    With Construct's ability to import a set of images and crop the transparencies, is there any point to using identically fixed-dimensions for each sprite in an animation? It feels like since I can set the origin point to the same absolute location across a set of frames that I don't have to worry if each frame in a given animation has varying sizes. Additionally, like most people using Construct, I use a separate platform sprite for purposes of collision detection.

    What does everyone else think?

  • DuckfaceNinja

    That's what I refer to as "unpacking/packing" in my original post. It's inelegant for a number of reasons especially if you want to preserve a "is host/peer agnostic" type of architecture in the code.

    In order to address the problem, I had to create a top-level function called "CustomSendMessage" which takes three parameters:

    • DestinationId
    • Tag
    • Message

    There is a special global tag I created called "RELAY_MESSAGE" which I will reference later.

    Let me outline the function's logic branches for you:

    • Function is being called by the host: no wrapping is necessary, use Multiplayer Send Message normally.
    • Function is being called by a client but the destination is the host: Again no wrapping is necessary, use Multiplayer Send Message normally.
    • Function is being called by a client and destination is a client: Send a message to the host with Tag (RELAY_MESSAGE), message is modified to be: DestId & "|" & OriginalTag & "|" & OriginalMessage

    Now we need a Host-only Multiplayer On Message RELAY_MESSAGE received logical trigger:

    • Unpacks the modified message, prepares to send a normal message to the true peer DestId with OriginalTag
    • The modified message becomes: Multiplayer.FromID & "|" & OriginalMessage

    Whenever a client receives any message, they have to determine if the true sender was the HOST or a relayed client which is done through a custom function called:

    GetTrueSender (string Message) - Returns Multiplayer.FromID or a token if the true source peer id was packed into the message.

    It works and solves the problem since the messages in my app are fairly infrequent, otherwise this solution might possibly introduce some latency in a different type of app.

    Either way, I'm still having to write a bit of kludge in that I'm adding a potentially unnecessary man-in-the-middle if it is actually possible to send direct messages peer-to-peer. However, this may be a limitation of WebRTC (all messages have to be sent to the peer-to-host-to-peer), I haven't done enough research.

  • It would be great if we had an action that could send a message from a peer to a non-host peer and the host would automatically handle relaying it. I can get around this with some fancy footwork and awkward packing/unpacking functions, but this would save some time:

    Multiplayer.RelayToPeer(Destination Id, Tag, Message, Reliability)

    • If this action is used from host, it functions like a normal Send Message.
    • If this action is used from a non-host peer, it sends the message to the host which would relay the message to the appropriate peer id and also preserve the true from id.

    *** If this is considered too in-depth ***

    Maybe could we just add a simple action BroadcastToSinglePeer which adds a DestPeer Id field?

  • So I've been doing some experimentation with Facebook integration for my app and noticed that the UserId that I was pulling from the Facebook plugin no longer matched my Facebook user id.

    After some research, here are my findings:

    • Since the Graph 2.0 API was introduced by Facebook, you are no longer going to get new user's Facebook User ID, instead Facebook will give you the "app-scoped user id". Near as I can tell, it's still unique, but definitely something to be aware of. I don't know if you can get the original user id based on an app-scoped user id.
    • The Scirra Facebook plugin is fetching the app-scoped id and using the javascript parseFloat to convert the value. Unfortunately, this seems to very occasionally introduce decimal values to the id, for example, when testing with my Facebook account, the app-scoped id changed from 38742387293 to 38742387293.0005. I made a modification to the actual Facebook plugin to return the app id as a string but anyone who doesn't feel comfortable modifying JS code can *probably* just use a floor command on the number.
  • Jeff Skyrunner

    oh, gotcha. :) That's typically the way that I do it as well; I usually setup a folder hierarchy in the Event Sheet, so I have an Enemies Folder and then have event sheets for each specific Enemy, OgreSheet, TrollSheet, OrcSheet, HobgoblinSheet, etc. (Depending on how much customization each enemy has from the generic enemy "parent" behavior)

  • Jeff Skyrunner:

    As a long time C# veteran I'm not sure I agree with the comparison of event sheets to classes. If anything, the closest thing to a class that construct has would be a sprite object (with some set of member properties) that acts as a Construct container for any complex class members (such as Array, Dictionary, etc) coupled with On create/On Destroy events to represent object instantiation and disposal. Inheritance is sort of mimicked by the introduction of Families.

  • Well, given that internally all the visual events are being turned into XML anyway, it would take a different kind of parser that could parse a construct text grammar and translate back/forth into XML. Add intellisense, color syntax, highlighting and it would be pretty nifty. A text interpreter is not something that would have to be coded from scratch, there are plenty of libraries that could be leveraged. I'm not saying it's a trivial task, but it's doable.

    Most of the people I know who come from a coding background and use Construct's main complaint isn't that "they can't do everything with scripting system that they could with coding", it's that (to their eyes), it's that a traditional coding environment makes it easier to trace code flow and keep things organized. And I get that; even with zooming out/etc, an entire screenful of Construct 2 events would probably shrink to a mere paragraph of script text.

    It also makes things a little more resilient, copying/cutting/pasting text is a just naturally less prone to potential weird failures that might happen when moving events between event sheets. Having text coding would also potentially make cutting and pasting between Construct projects easier as well, not to mention stock text editor stuff like Find, Find/Replace, etc.

    That being said, the keyboard control has come a long way though occasionally you'll lose input focus in the event sheet and have to click on something to bring it back so you can continue using the keyboard.

    Even though I'd certainly appreciate the ability to script using code, given the amount of feature-work Scirra has on its to-do list at this time I tend to lean towards making something like this low priority.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • I've got a quick question for everyone using tilemaps. It seems that Tilemap is primarily concerned with the rendering aspect of a map. What is everyone doing to encode additional information on a tile by tile basis? Example, let's say you wanted a property called "IsBurning" on any tile position. Eg, Tile ID 1 at position (5, 8) is burning, all other tiles of ID 1 IsBurning is set to false. So each instance of a tile in the map would have a set of properties.

    The only thing I can think is that I'll need to create a separate 2d TileProperties array with each value set as a lookup for the UID of a TileDictionary for all the properties. I could also optionally use string concatenation in order to use a single dictionary, so something like:

    TileDictionary["Tile_" & TileX & "_" & TileY & "_" & PropertyName] = Value

    That would let me avoid having to create an array.

    Thoughts?

  • Dictionary/Arrays could work but if the function is recursive or calls other functions which rely on the same Dictionary/Array you could accidentally overwrite existing return values (unless you create dict/array each time).

    I've used the string splitting option before for returning values.

    Another approach that I use is creating specific Return Objects. So for example, if I have a function that needs to return a IsStunned boolean, a Damage number variable, and a string TypeOfAttack, then I would create a Sprite object called RetAttack which would have IsStunned, TypeOfAttack, and Damage as instance variables.

    The function would then spawn a new instance of this object, assign the variable values, and the function's return value would be the UID of the RetAttack object.

    I like this approach since it provides strongly-typed returns that can be complex objects, and there is no unnecessary parsing/type conversions either (as would be the case if you joined all three in a single string).

    After returning, you would pick RetAttack by the ret UID and extract the return values (TypeOfAttack, IsStunned, Damage) then destroy the RetAttack object.

  • Link to .capx file (required!):

    dl.dropboxusercontent.com/u/12667027/Construct%202/Bugs/ErrorRenderingViewBug.capx

    Steps to reproduce:

    Resize/Move any object in layout.

    Observed result:

    "Error Rendering view: Failed to read image file data. To prevents floods of alerts..."

    After this if I try to proceed, Construct 2 completely crashes.

    I have tried to strip down the project as far as I was able to and have the problem still occur. I'm extremely frustrated at this point as I don't know how to debug this problem and its basically brought my entire project to a halt. Is there a crash log? I couldn't find one.

    EDIT: I recreated all the assets in a new project, and copied over the event sheets, so I'm not blocked at this point. whew...

    The problem inexplicably occurred (although I'd already saved before I noticed it) after changing the Font Scale property of an instance of a SpriteFont from 1.2 to 1.35, following this project immediately became corrupted.

    The daily backup is at least 4 hours of solid work behind, and a while back I had to uncheck the "Keep 2 backups of save within folder" since it occasionally recursively saves the previously autosaved compressed capx files as part of the new save capx resulting in steadily growing "save files" in excess of 100s of megs.

    Browsers affected:

    N/A

    Operating system & service pack:

    Windows 7 64-bit SP1

    Construct 2 version:

    Release 142 (64-bit)

  • Without a sample capx, it's difficult to ascertain why this problem might be happening. Are you creating object A in an "On Start of Layout" event anywhere?

  • firebelly:

    Yeah, I would ordinarily have created a new sprite plugin for these features but my proj already has 50+ Sprite objects and I didn't feel like futzing with the xml to point them to my modified Sprite.

    As it stands, I wrote a little standalone patcher which modifies the js files and adds my changes to the relevant files so that whenever I update Construct 2 I can put my stuff back in quickly.

cacotigon's avatar

cacotigon

Member since 10 Mar, 2009

None one is following cacotigon yet!

Connect with cacotigon

Trophy Case

  • 15-Year Club
  • x2
    Coach One of your tutorials has over 1,000 readers
  • RTFM Read the fabulous manual
  • Email Verified

Progress

18/44
How to earn trophies