Dalal's Forum Posts

  • This is a great example. Thanks man! This answers my original question.

  • Constant instance variables (or 'instance constants'? :p) would be terrific in their own right. Even so, I think traditional 'Enums', for me, excel at 2 important things that make them especially worthwhile compared to other approaches:

    1. Forcing a single choice. An enemy can't hide and attack at the same time. In code, instead of having to specify a priority order, one could simply select 'State.HIDE' from the list and call it good - super clear and less prone to buggy logic - like using a Boolean instead of isTrue and isFalse vars (hopefully no one has ever done that). Plus, the idea of a neat little drop-down in the C2 user interface when testing against an Enum really excites me.

    2. Less prone to typos. True that Javascript enums are just strings, but I guess there's also the possibility of using the Object.freeze method to seal a property into an effective Enum, eliminating the typo issue. I feel like in many cases in JS games, this would be more desirable than using dynamic JS enums. Likewise, in C2 having an Enum in many cases would be preferred to using strings or constants.

    All in all, I think Enums would be an awesome addition to have down the line, but I see why this wouldn't be an immediate priority because there are a handful of alternate approaches.

  • Let's say you had an instance variable called state that can represent three states: HIDING, CHASING, or ATTACKING. Without Enums, the best approach is to use a Number for this variable, and then declare global constants in the following manner: HIDING = 0, CHASING = 1, ATTACKING = 2. Now you can use these constants in your code with full control over them in case things were to change.

    That works fine for one object, but now consider you have 15 different objects with different state values. That's a lot of global constants and can make things very unclear in the code. This issue could be eliminated if we had an Enum instance variable type. With an Enum, every state would be self-contained and it could be easily referenced in the code.

    Is this planned for a future release? If not, why not? Instance Enums would be handy ex. intelligent enemies (hiding, chasing...), characteristics (sharp, smooth), etc.

  • I put a hold on the project I was working on at that time, so I never really got around to finding a solution.

    The best approach I can think of straight off the bat is to use a Sprite Font with fixed width. Knowing the width of the characters, you could anticipate when a word will flow to the next line and place it there beforehand using a line break. That would be the general idea.

    Also, I recently saw another C2 game (can't remember which one) that had this same problem, but seemed professional in almost every other way. It really bugs me because I haven't seen a single professional release that messes this up, yet most beginners implementing the typewriter effect don't seem to mind the visible word wrap. It looks disgusting to me

  • There is no such thing as a secondary 'then'. An event is an 'if' statement. So a sub-event is an 'if' statement within an 'if' statement. Like this:

    if (Condition1)
    {
      // actions
      Action1();
      Action2();
    
      // sub-events
      if (Condition2)
      {
        Action3();
        Action4();
      }
      if (Condition3)
      {
        Action5();
      }
      
    }
    

    Condition 2 and 3 represent sub-events of the event defined by Condition 1. They occur inside the scope of Condition 1 so they have access to everything defined within Condition 1.

  • Awesome! Great timing. I'm looking forward to the next release. Thanks Ashley!

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Could you use the Gamepad plugin to achieve what you want?

  • There doesn't seem to be a condition in Construct 2's Sprite object that tests if a point (x,y) lies within the sprite's collision polygon. I feel there are plenty of reasons why such a condition should exist natively in C2:

    1. It provides fundamental information about an object's collision polygon that can aid in writing advanced custom collision detection code. Consider objects that climb slopes along their bottom-center image point but retain the information needed to use their bounding polygon when testing for collisions near edges, where their extremities must be off the edge if they are to fall. Or perhaps consider a scenario where you want to test if one object is fully contained within another.
    2. It provides a neat, reusable method for fetching information of this nature. Without this condition in C2, I would have to use a single pixel sprite. If I were to use this sprite and position it to the point in question each time I were checking for overlap, I would have to repeat this series of events for every object in question. It would be difficult to see at a glance what point I'm comparing against because those values would be overshadowed by the logic of the algorithm that involves positioning the sprite, etc. Functions won't work because then I would have to pass a parameter that refers to the object whose collision polygon I'm testing against. Let's say I pass it's IID. I don't see a way to Pick an object with an IID and test for overlap with it. I could use Families and UIDs, but that still makes it far more complex than it needs to be.
    3. Something as intricate and precise as a collision polygon could be used in countless ways, but we are presently only given one limited usage of it: to check if two objects overlap. The power and flexibility of defining a collision polygon to sub-pixel precision seems wasteful when only one essential use is allowed. More open access to the collision polygon (by way of checking if a point lies within it) would significantly increase the programming possibilities available to the game developer with very little increase in software complexity.

    All in all, I think this would be a great addition to C2. I apologize if there are already simple approaches to finding whether a point overlaps an object, but I asked in the 'How Do I?' forum and no one seemed to know of any.

    Thanks for considering my request!

  • I don't see any conditions that check if a point (x,y) is within the collision polygon of an object. Is there an event I'm overlooking, or will I have to use a single-pixel sprite to accomplish this?

  • I believe the reason your approach is not working is because it's 'picking' both sprites rather than just one. Here's how you might fix it. Let's assume your sprite is called 'Sprite'.

    First create a family called 'SpawnedObjects' and add 'Sprite' to it.

    Then, in your events, check to see if the newly created object 'Sprite' is overlapping any 'SpawnedObjects'. If it is, then position 'Sprite' to a new location.

    This way, you've differentiated the created sprite from the already existing one. You've identified 'Sprite' as the newly created one and 'SpawnedObjects' as the existing one. Simply move 'Sprite' and it should work.

    Also, if you're not already doing this, make sure it continues to re-position 'Sprite' until it finally finds a spot. Use a loop. Otherwise, it might re-position 'Sprite' once to avoid the overlap, but won't re-position it if it happens again.

  • Basic implementations of the 'typewriter' effect fail to account for word wrap. Because of this, you see several amateur applications where words that are being typed out suddenly 'jump' to the next line. This looks unprofessional and is undesired in most cases.

    What are some ways in which a cleaner typewriter effect can be achieved in C2, where words that should end up on the next line start out on the next line, to avoid the 'jump'?

    So far, one possibility I've thought of is to use the 'text height' expression of the text object to 'peak' at the next word before typing it out. If the text height changes after the word, then start it out on the next line. If not, spell out the full word. In this manner, you would go word by word and it would cleanly type everything out.

    Are there any better approaches you can think of?

  • Change the 'Set Angle' property for the 8-directional behavior to 'No'. I believe that's it.

  • Hi guys, I was wondering if it is currently possible to export a Windows 8 project from Construct 2 to submit to the Intel AppUp Store. Submitting to the Windows store is easy through the 'Export for Windows 8' option and Visual Studio 2012, but submitting to the Intel AppUp Store seems to be a mystery. I'm just not understanding how Windows 8 apps work. I figured there would be a way to package the Visual Studio project 'binaries' into a format the Intel AppUp store can understand. Can someone lay down the knowledge on this?

  • I've settled on replacing the Animations folder and replacing the <animation-folder> node in the .caproj. Looks to me like there would be no problems with this approach, except accidentally corrupting the project somehow. I'll just backup my project before doing the change.

    If anybody knows of a cleaner way to replace an object's animations, let me know.

    Thanks!

    Dalal

  • Perhaps Families are what you are looking for:

    scirra.com/manual/142/families