cacotigon's Forum Posts

  • 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.
  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • 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.

  • 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.

  • You can scratch 1 and 4, I went ahead and added them to the default Sprite plugin javascript so that I could make use of them in my projects. <img src="smileys/smiley4.gif" border="0" align="middle" />

    I guess Clone would be the singular most important feature out of these that I'd like to see in Construct. There's just not a clean way to implement something like this in Construct 2 through events, since we can't create/spawn by "string name".

  • I'm sure most of these are already in the "what I presume to be massive" suggestion box, but I thought I'd throw them out anyway:

    1. Family.ObjectName( Event/Expression) - Get the project-defined name of an object within a picked family list. If current Family SOL list is greater than one, it does the standard Construct 2 behavior which just returns the ObjectName of the first one in the currently picked Family set.

    2. Clone object (Action) - Copies all instance variables, position, etc. The only things that would be new would be UID and IID values.

    3. IsBehaviorActive (Event/Expression) - We can already disable/enable behaviors through events, it would be nice to also have a Platform.IsBehaviorEnabled/Bullet.IsBehaviorEnabled/etc (it would help save having to declare an instance variable)

    4. Sprite.HasAnimation(string animName) - Expression/Action - returns true/false as to whether an animation of some name exists for a given sprite. This would be an incredibly useful since I am frequently adding sprites with specific sets of animation names and have generic code to handle switching between them.

    And lastly I wish to impart my sincere appreciation for the work and care that has gone into Construct 2 in the first place!

    Thanks,

    -- Cacotigon

  • DevRaccoon:

    Prox is correct, your function signature parameter expects a *single UID* as its Param(0). When you use the obj_creature Is Active, you filter your SOL list to just that set of creatures, however, when referring to expressions such as obj_creature.X or obj_creature.UID, internally Construct has no idea which element in that array you're referring to, so it just picks the first obj_creature in the filtered picked list for that property. It doesn't pass that group of UIDs as a collection, it passes a single one to the Function, so you have to call the Function() *once* for each creature.

    That being said, in general, you want to do as much filtering as possible before the for-each call to optimize performance. Instead of iterating across the entire list of obj_creature and doing the "Active comparison" each time, it's better to pick/filter first, then use for-each:

    <img src="https://dl.dropboxusercontent.com/u/12667027/Construct%202/FunctionForEach.png" border="0" />

  • ChrisAlgoo

    You're very welcome. I also added a new section to the bottom of the tutorial where I discuss the performance aspects and advantages of Family to Family collision detection.

  • Animmaniac

    As I understand it, the way the engine is setup it can't really do a single nested loop for all collisions internally, because the user can setup all kinds of different collision detection wherever they want (even between events/actions that could change the positions of objects) in their event sheets.

    EDIT: Ignore this next paragraph, I'm clearly tired as this would very much *not* address the order problem that I just described, aka events which change positions of objects.

    (In order to do something like that, it would have to "read-ahead" for all possible collision checking events, aggregate them, filter for the distinct checks and remove duplicates, run the collision detection against this unique set, and finally store this in some kind of temporary Game Loop Cycle CollisionMap which any Collision events would just internally map against.) -- Bla bla bla

    EDIT: Resume reading here. :)

    Out of curiosity, I just did a profiling test of the two approaches:

    Object to Family

    Family to Family

    Family to Family is about ~1.5-2x times more performant.

    Benchmarking Capx

  • Animmaniac

    I'm sorry but it would increase the number of unnecessary checks, let's break it down item by item. Maybe if collision checks between objects were cached, but as Ashley has confirmed in a previous thread of mine, they are not.

    Let's say you have a family with three objects X, Y and Z, and one of each object in your layout.

    Using your system of checking object to family collision, you would have three events:

    X On Collision with Family: This would internally run two separate collision checks: X-Y and X-Z

    Y On Collision with Family: This would internally run two separate collision checks: Y-X and Y-Z

    Z On Collision with Family: This would internally run two separate collision checks: Z-X and Z-Y

    Making for a total of 6 collisions

    Not let's see what would happen if we used Family to Family collision:

    Family On Collision with Family:

    Checks X-Y, X-Z, Y-Z

    X-Y is the same as Y-X

    X-Z is the same as Z-X

    Y-Z is the same as X-Y

    So in your example, you perform 2x the number of collision checks. You can imagine that for 100s of objects in a game, this just wouldn't scale well.