santiagoestrade's Recent Forum Activity

  • Basically, the statement above. I am testing with several capx (from me and from many examples on tutorials and posts) and it always happens the same.

    When having a Tilemap, it shows up correctly on the layout. But at preview, if no other sprite instance is inserted on the project (not at runtime), tilemap never shows up.

    This is an example of mine, but you can try with any project woth a tilemap and some sprite.

    1drv.ms/u/s!AojCIgmN1VlPiXHgVYT1aGqqT9-6

    If you delete the troop, arrow and line which are outside the viewport and then prev, screen is blank (black, actually :p). Were any of them onto the layout, tilemap shows up as it should.

    Maybe I am missing some point on how tilemap works? Or some parameter I didn't notice had to be set up on the properties bar?

    I know it could be worked around by adding a destroy action into the first event, since I do know they all have IID 0, due to being the first ones created. But it's a bit odd.

  • tarek2

    I solved the double tap issue!!! It was just a matter of adding an AND condition when touching the tilemap, so that it only repositions arrow if recognizes tilemap being touched, but not arrow. So if I touch onto an 'empty' tile, arrow goes there, because it was not touched at the same time. But at double tapping the arrow for locking the target, the condition of the arrow being touched forbid the tilemap-event to trigger, because it only runs when the arrow not being touched.

    - TAP TILE TO POSITION ARROW:

    + Touch: On touched Tilemap

    + Touch: [X] Is touching Arrow

    -> ArrowLine: Set position to (Tilemap.SnapX (Touch.X), Tilemap.SnapY (Touch.Y))

    -> ArrowLine: Set angle toward (Tilemap.SnapX (Troop.X), Tilemap.SnapY (Troop.Y))

    -> ArrowLine: Set width to distance(Self.X, Self.Y, Tilemap.SnapX (Troop.X), Tilemap.SnapY (Troop.Y))

    -> Arrow: Set angle to ArrowLine.Angle + 180 degrees

    -> Arrow: Set position to (Tilemap.SnapX (Touch.X), Tilemap.SnapY (Touch.Y))

    - DOUBLE TAP ARROW TO LOCK TARGET:

    + Touch: On double-tap gesture on Arrow

    -> Troop: Set TargetX to Arrow.X

    -> Troop: Set TargetY to Arrow.Y

    -> Troop: Set TargetLocked to True

    -> System: Set ActiveTroopUID to 0

    1drv.ms/u/s!AojCIgmN1VlPiWjfQMhXp4MCGcdS

  • Great man!!! I really really appreciate it. Finally I do understand the logic of managing instances.

    That make sense now. I was adding tons of non-additional worth events hindering the whole behaviour of the sheet. Triggers where weren't needed and system everyticks for triggers-to-be. That explains inconsistent results.

    I think for the moment I'll stick to the global variable for checking the active troop/arrow. Being a rookie, I am afraid won't be sure that after 'deactivating' each troop, no instance will be left with its variable set to inactive. With the global I ensure there's always just one active. But I know what you mean. Once I get used to picking, triggering and indenting in the right way, I'll manage variables individually to clear all. And definitively will need to make some of them functions. Sure I will have to call them at some other point for wahetever reason.

    You're right. Too new at this and trying to solve every bit at once. I'll deal with them one by one. And next time will be posting quoting the proper posts/tutorial with just the point I don't get (and after working with some related capx, I didn't realize how helping is to actually see the event sheet; I now understand why you advised to explain my issue step by step, for sake of logic).

  • I indeed have read about containers, but got it the wrong way. By saying take one object, create a container and then add more objects, I thought it was kinda sub-events, one being parent, so my (wrong) underdtanding was:

    -if I destroy troop (parent), arrow gets destroyed

    -if I destroy arrow (child), troop stays.

    So nothing about it. Just behaving as a regular group. Lesson learned!

    The issue about "calling" arrows is a matter of idiom. I meant that I could pick an arrow based on its troop IID and viceversa. They should be supposed to have the same IID. So if I have global variable ActiveTroop set to Troop.IID on touching that troop, picking its arrow would be pick nTH (ActiveTroop). It may serve for picking both troops and arrows without adding another variable, let's say ActiveArrow. Just thinking in advanced for future functions. Or some way of doing the arrow drag&drop method.

    When I talked about creating, I was stating the case in which I didn't add instances on the layout, yet creating them with events on runtime. To make sure their arrows are created in the same order and share IID. In my capx, there are two troops but only one arrow, so the other arrow has to be created 'by the container'.

  • tarek2

    Not necessary at all the double tap trigger. I wanted a three step method in case you wanted to change your mind once you had touched on target tile. So after touching target tile and "deciding it's ok" you 'do something' to lock the target. Because each troop is not going to move at the time target is chosen. You go picking troops one by one and targeting. Then, at the end of turn, every troop moves. Also in case you decide to choose another troop once you have already touched onto a target tile.

    But double tapping could be sustituted by any other trigger. I was thinking a slightly more elegant solution. Placing the arrow invisible behind the troop. Allowing to drag the arrow with BoundedDrag&Drop. So touching on troop activates it (the arrow actually). Dragging sets the target. And then touching on arrow locks the target. But it's been even worse for me to implement since I have such little kbowledge of events.

  • Oh I see now. At some point my timeline got blurred. It seems I had updated everything according to your tips and some time past answered you, so completely missed my point.

    Anyway, now it's a dofferent matter, thought related in some way. If you look at my capx now, it behaves almost as it should. Except for the arrow not changing visibility as I expect. Creating and destroying them each time would solve that. But in that case, using IID would not reference always to the same instance, ain't it? I have read that it reorders with the instances leftm But in another topic, someone mentioned somrtjing about runtime having 'memory' for the instances previously created/destroyed so it doesn't have to write/load all again.

    I mean- I have two troop sprites with an arrow for each into a container. I call troop and arrow by IID. When touching troop, creates arrow, when moved to arrow, ot gets destroyed. Next time that arrow gets created, gets assigned again the previous IID, due to being related to the troop IID through the container, or simply stacks as the last IID?

    I am trying to figure out the best way to work with them in the future. I know will have to create functions and would be nice to plan how will I be calling then and the objects. Still reading about the topic to avoid bothering you guys so much.

  • I am finding some issues that I can't work around, at least the way I would like.

    The main issue keeps being arrow visibility. At touching troop, arrow shows up and though a set invisible action is set up, it doesn't disappear.

    I am already struggling to arrange events and picks in order to 'erase' the previous not-locked arrow if touched on another troop.

    The other issue is about the arrow not fading out at all. I've tried with at collision troopVSarrow, on troop at targetX, targetY, on troop at ArrowX, Arrow.Y, on troop overlapping arrow, on troop moveto stop, on arrowline width=0... Arrow always visible.

    Maybe I am looking at the wrong direction. Should I create/destroy arrows and lines instead of setting opacity or visibility?

    Double tap is definitively a problem. The first touch repositions the arrow if not touched on the exact point, because it recognizes the tilemap being also touched. So it is always a tap on arrow/tilemap followed by another tap on arrow/tilemap. Is there a way of making the tilemap "untouchable"? Being that the case, I can allow to touch the arrow to lock the target without touching the tilemap and triggering the reposition.

    And a last strange point- I have two troop sprites, each one on layer2. They both have arrows, but just one is 'drawn' onto the layout, on layer1. The other one gets created automatically, because of being into a container with the troop sprite. The troop instance whose arrow&line are already on the layout visually overlaps them while moving, as it should be, since they are onto a lower layer. But the troop which creates arrow&line automatically due to container gets behind them, even being onto an upper layer. There is no way of having them behind without pre-inserting them onto the layout? I have checked in case system was creating the 'containered' sprite on layer0 and even manually set to layer2. But it behaves exactly the same.

  • tarek2

    Ok I'll try to understand every piece of advise you gave me.

    The thing about picking I knew was a flaw of mine. But I am not using nTH (which I suppose it's the one that takes the IID, referenced just for their sprite, so being into a container and created at the same time as their parent object, should always have the same IID, if I understood what you meant), but pick by evaluate variable, so I check the global variable Active troop. I tried with the sprite pick by UID by for whatever reason it always picked both instances or none. Now it is picking the right one.

    I tried even with your capx, replacing the picking nTH to 'pick by evaluate' and works with UID as it does with IID + 'pick by nTH'. Tried also with system compare variable and also picks the right one. The point is I think not to understand correctly the benefits of picking by IID instead of UID. Talking about containers- according to what I have read, on a sprite created, each other attached sprite in his container is also created. So they are always created in the same order. So they should have the same IID. Don't they? In my case, first troop has IID 0 and his arrow IID 0 (first instance of his object) too. As second troop is created, it gets assigned IID 1 and his arrow is created also with IID 1 (second instance of his object). That way is simpler to relate them. Did I understand correctly?

    Right now, with system compare by evaluate picking condition each troop is moving towards its own arrow. I added a boolean instance variable TargetLocked which sets up at double tapping tilemap/arrow, thus confirming target. Then, when skipping turn, an AND condition picking instances with TargetLocked true.

    Indenting all the arrow and target as a sub-event I did as well and everything seems fine with that. The point is that at tapping the troop instance, arrow shows up, when it should have been set invisible. That is an event-order issue I suppose. Will work on that.

    My main problem now is When I tap a different instance, the arrow of the previous ibstance I had activated before, still keeps visible.

    I see what you mean with the every tick on the arrow line. As you say, I am no as used to event arranging. So my guess is condition should be 'Troop is moving'.

    Even the thing about not being able to double tap!!! I know what you mean. By indenting the event, I ensure each double tap 'belongs' only to their picked troop instance. But the point is that if I have Touch.Tap as a condition on the parent event, it is no longer showing up to be selected as a condition for the sub-event.

    C3 simply doesn't allow to say:

    -parent condition: tap on instance

    - sub-event condition: double tap on arrow/tilemap

    I am not sure if I understand correctly what you are explaining about triggers. Could it mean that 'double tap on tilemap/arrow' can't be conditioned as a sub-event of 'tap on troop' because they are both triggers, so runtime would expect to happen at the same time? That would explain why the first touch of the 'double tap on tilemap/arrow always triggers the 'tap on troop event'. So... if changing the sub-event condition to 'is touching tilemap/arrow' wouldn't make it succed either, as I have experienced.

    Maybe the link for my capx didn't updated when I was working on it last night.

    Here is again:

    1drv.ms/u/s!AojCIgmN1VlPiWjfQMhXp4MCGcdS

    Thanks again for taking the time to help. I know it's a basic issue, but coming from a non IT background, reading the forum, tutorials on scirra and the manual don't happen to clear my mind. And any pointing in the right direction is most appreciated. I'll play around with your capx to see if I can understand.

  • dop2000

    I am failing to apply this to my project. At the moment I have more than one instance, I managed to make each one sets up their own arrow to their own target. Yet they both eventually move to the same position- left upper corner. Not referencing each one their own target instance variable Troop.TargetX, Troop.TargetY (though I also tried MovedTo their arrow object due to container, or so I intended, and the outcome was even worse, they didn't moved at all).

    I have messed with sub-events, trying to understand the difference between system 'pick instance by evaluate' and sprite 'pick by unique UID' conditions. I have chosen the system pick condition because of a so-believed repeated object incompatibility when making sub-events that I'll further explain below.

    Another issue comes when I try to make a sub-event from the same object of the parent condition. I'll explain:

    I want to touch a troop instance. And then, only if I touch onto a tile (and only if I touch on a tile after having touched/activated a troop instance), arrow shows up.

    If I don't touch onto any tile and instead I tap any other instance, it should just change global variable active troop to that instance, thus becoming available for targeting a tile with the arrow showing up)

    Would I have touched a tile and the arrow showed up, I could already tap on another troop, so that previous arrow sets invisible and the one from the new-tapped troop sets visible (not at that very moment, but when I later touch on a tile). Well, that arrow never disappears...

    The point is that if I have a 'On Tile tapped' condition, at the moment I try to make a sub-event (for locking just the selected tile) with 'on tilemap double tappef', it just isn't there as an available condition. It only allows to check if it's in touch at the moment, which simply can't meet my purpose. I suspect I am not getting the point of how events order work (yeah... I have read the manual).

    So I have to move the On double tap condition to a new event below, and then can't lock the instance I am working with at that time. It's hardly possible to accurately reach with the finger the point where the arrow is, specially since is blinking and seems not to be touchable when not visible. I tried making it a simple double tap onto the screen, but at the first tap, it recognizes it as a tap trigger and sets the arrow to the point where I touch. How can I work around this? Is it possible to double tap without C3 taking into account the first tap? Is it due to having another tap condition? I'm a bit lost on this, for would bet if I where able to make the double tap a sub-event of the tap event, it would wolve the problem. No reason behind, indeed. Just a hunch.

    I don't know whether may be necessary to include some sort of loop, like 'for' or 'for each'. Or I might be arranging events and sub'events in the wrong way. Or not understanding picking instances at all. I tried also to add an else condition to set invisible every arrow which is not locked yet, but didn't succeed either. Or backing off to the instance variable active|inactive and comparing values.

    Moreover, I have set the set arrow visible/invisible action when I tap a tile. But it shows up when I tap the troop. Maybe because of the container.

    I am a complete mess rith now. Have rewriten once and once again the event sheet shifting between conditions, actions and variables and still being unable to join everything altogether.

    1drv.ms/u/s!AojCIgmN1VlPiWjfQMhXp4MCGcdS

  • dop2000

    That's awsome! You understood exactly as it is. That was my intention. And you even optimised it in just a few codes. I'm spending these days trying to apply this brand new approach to my project.

    Eternaly grateful mate!!!

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • dop2000

    Sorry I didn't explain the whole situation in the first time.

    I have, let's say 20 troop instances. When I touch on a troop instance, it changes with some effect (shadow, color, light,... doesn't matter) and 'activates just it' so that if I then touch on a tile, an arrow shows up from that troop towards the tile which I touched.

    There is a small option to change the target for a troop. You may have touched a tile by mistake, or decide to move another troop instead. When I touch a tile for the first time, it starts blinking and when I double tap, flash disables and arrow gets locked. Then, that troop instance becomes inavailable for chosing until next turn.

    But the instance doesn't move yet. Then, I touch another troop instance, again onto the tilemap, and then the arrow. And so on until no troops left for choosing. Then you say to 'skip turn' (in any way, I didn't decided it yet, whether a button, double tap or else) and every instance moves along their own arrow to their target tile. And also the movement of each troop should be 'erasing' the arrow, but no worties with that, because it's the same thing you teached me before with every tick setting arrowline width according to distance.

    I have done everything right when working with just one instance. But at the moment I create the rest, it's complete chaos.

    I am figuring out some ways to make just one instance moves, like placing an instance variable which can be 'state': active | inactive (this actually came from you on another post, talking about ternary operators). When I touch the troop instance, it sets every other instance to inactive (in case you choose one and then decide to move another one), then sets the variable active for that instance and then compare which instances are active for the arrow event to happen. At double tapping, it locks the arrow and sets inactive again the instance.

    But I don't know how to call the movement of each troop instance for their own arrow. I am trying to understand how to call a specific instance of an object, to ve able to reference it to the troop. I mean, something like- move to the arrow instance that was created afeter touching you, or the arrow touching the line that touches you, or something of the like. I don't know either if it' possible to relate the arrow instance created at touching the tile after the troop with that very troop instance touched before. Something along the lines of containers maybe...? Pin behaviour with variable attaching point?

    Maybe a position variable for each could solve that?

    I am running out of time and really busy these days, so I hardly can access my PC at night, just taking every bit of spare time to learn C3 with the smartphone. I'll link to my C3P later

  • But I have several sprites which behave the same, except for their atributes (health, range, power,...) and their position. I am struggling to be able to move one instance only, but they always move alltogether

santiagoestrade's avatar

santiagoestrade

Member since 25 Mar, 2016

None one is following santiagoestrade yet!

Trophy Case

  • 8-Year Club
  • Email Verified

Progress

9/44
How to earn trophies