dop2000's Forum Posts

  • The best way to deal with this is to add Player and PlayerMask into a container. And same with the Enemy and EnemyMask.

    This way when you create an EnemyMask instance, its own Enemy instance will be created automatically. And they will be logically linked. So, for example, if you pick Enemy in an event, its EnemyMask will be picked as well. Read about containers, they can really help here.

    Also, it's not recommended mixing Physics with Platform or any other non-physics behavior. And I don't know much about Spriter, but I'm guessing it's not very compatible with physics either.

  • What do you mean by "collided monster"? Inside this event you picked an instance of Monster family which has collided with the weapon. So I guess what you need to do is subtract 1 from MonsterHealth, or something like that. Only the instance which collided with the weapon will be affected.

  • random(2) is a number from 0 to 1.99999999999

    random(1,3) is a number from 1 to 2.9999999999

    So yes, floor(random(1,3)) is the same as choose(1,2), and represents 50-50 chance.

  • Here is what I would probably do:

    dropbox.com/s/56j5rby2vg591lj/MouseAndTouchToFunctions.c3p

    You add all clickable/touchable objects to families. And replace all "On touched", "On object clicked" etc. events with functions. Map these functions, so you could call them by name. (this may be easier to do with the old Function plugin)

    Of course, this is a very basic example. You can add more things, for example create two global variables MouseTouchX and MouseTouchY. Add an event at the top of your event sheet which will set these variables to either touch or mouse x|y coordinates, whichever is active. And in all other events use these variables.

  • Run the game in debug mode (Ctrl-F4) and see how much memory and CPU it uses and what changes when it becomes slow. If you click "Profile" tab, you will be able to see most CPU-consuming events.

  • Set physics world gravity to 0. Also, it may be much easier to use Bullet behavior instead of Physics, just set "Bounce of solids=Yes".

  • It shouldn't be a lot of work. Use the invisible sprite for movement and everything collision-related (collision with walls, bullets, enemies etc.) Use Character sprite for animation changes and everything else. Pin character to the invisible sprite at start of layout.

  • Your Update function is called twice, but the second time there are two "1" values in the array, that's why you see total 3 "hellos" in the log.

    Add more log outputs and you'll be able to see this:

  • It's not a bad code, I just didn't really try very hard to figure out what it's supposed to do :)

    As I understand, the issue is with picking instances of Item object immediately after creating them. You can only pick a newly created instance in the same tick by UID. If it's not possible, you can use wait 0 or find some other workaround. Maybe use a different array to keep track of created items or something.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Try Overlapping at Offset:

    Player is overlapping floor at offset Y=10
    	Set floor animation frame to 0
    
    Player is Not overlapping floor at offset Y=10
    	Set floor animation frame to 1
    
  • I don't think Turret will fire at a target which is blocked by solid.

  • Yeah, but there is no setting on Turret behavior to ignore Solids, so I'm afraid the only solution is to not use Solid on enemies. You'll need to prevent collision of tanks and enemies with events.

  • So when W is pressed, you call function "add" 3 times. In "add" function you call "update", so it goes add->update->add->update->add->update. These 6 function calls are performed one after another, but all in one tick.

    Inside the "update" function you check if Item with ID exists, if not, you create it. Object instance is not created immediately, you need to wait till the next tick before you can pick it by its instance variable. That's why your code works differently when you add "Wait 0" before function calls - it allows time for Item to be created.

    It's possible to fix this without "Wait 0" - for example, you can set some flag in the array when Item is created, but I don't really understand your code, so can't help with this.

    Also, if you need to see the order in which events are executed, add Browser Log action to your functions. Press F12, and you will see log messages in console. It's a powerful debugging method, you can output variable values, array contents, function parameters etc. and see how they are changing.

  • In events 4 & 5 you are picking Player instance. You need to change them to pick Enemy instance. So it needs to be "Enemy compare X..."

  • Your file is named "This thing YYY-3.capx.zip"

    You need to remove ".zip" from the end. To do this, you need to see file extensions in Windows. But, as I said in my previous comment, even if you do this, you will still not be able to open this file in Construct 2, because the project is corrupted.

    If you want to try fixing it, you need to rename the file to "This thing YYY-3.zip", unzip it into an empty folder and then manually edit caproj and all xml files.