Help with math expressions

0 favourites
From the Asset Store
Game with complete Source-Code (Construct 3 / .c3p) + HTML5 Exported.
  • 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.

  • 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

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

    That's Why I omitted it on my example as is confusing Plus you gonna have to do many extra Events + Conditions unnecessary just to accommodate the double Tap so it doesn't interfere touching with either (Troops or TileMap)

    is it really necessary to do the Double Tap? I will just keep it simple like the example I give you where I locked everything by steps (Touch Troop and Touch TileMap to set a Path) other ways it's Locked you cannot move

    I'm gonna have to recommend you to slow down take a breath and start from the beginning but start by following some Tutorials so you can understand the Basics, once you that all the problems you have now you will be able to resolve them very easy.

    I say this as an advice because I see like you trying to do everything in one go and you get overwhelmed as you can see on this thread, there are Pages and Pages of different questions an many of them have been answered already but you still don't see them, I personally got lost I don't know what you are trying to do, there is so many info and questions and problems on this thread its hard to follow plus there is no Time to read all the different problems properly. I give you an Extra Capx to follow see if you can understand by studying it

    Here are some Tutorials:

    scirra.com/tutorials/253/how-to-make-a-platform-game

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

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

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

    Ok that's new Info you see, the problem you gave to much info in one go and it was not clear what you trying to do, if you just tried to give simple steps of what you were trying to do most probably someone would have already gave you what you need.

    When I say simple I mean just make steps example

    1-Is Game troops they all will move on the same turn at the end

    2-To Give them a Path to move you have to touch object then touch tilemap to set coordinates for that object

    3-You can cancel object Path by etc......

    4-Arrows >>> I dont know what is going on with the Arrows so >>>>bla blaa blaaaa etc.....

    5-And so on

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

    =============================================================

    A

    =============================================================

    I call troop and arrow by IID. When touching troop, creates arrow?

    I don't know what you mean how can you create if you already calling the Arrow & Troop meaning the Arrow was already create

    also if you create another arrow a Troop will be created with it

    when moved to arrow, ot gets destroyed.

    Again if you destroy Arrow the Troop will be destroyed with it

    Next time that arrow gets created, gets assigned again the previous IID

    if it was only one Arrow on the Game and you destroyed and created, Again and again, it will be always

    IID =0 because that's the index on which is been created if you had more arrows still on the Layout it will give him a different IDD

    Did have a look at the Manual?

    scirra.com/manual/150/containers

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

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

    No Worries mate

    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.

    The purpose of the containers is to avoid what you trying to do "Adding More conditions" to pick the Arrow linked

    This is how it works

    if you Pick a Troop the Arrow gets Picked swell automatically

    or

    if you Pick an Arrow the Trop gets Picked swell automatically

    so meaning if I pick a Trop I can straight away make Actions to Arrow as is on a container and C2/C3 knows to which arrow I'm talking about

    Example I can do this:

    Pick Troop By (Whatever Method you like)

    Action: Set Arrow to (Whatever you like to Do)

    you see I didn't need to Pick the Arrow by Variables or IID because comes automatically Picked with the Troop, they are always together and they get destroyed together and they get Picked together

    Or I can do the vice-versa also:

    Pick Arrow By (Whatever Method you like)

    Action: Set Troop to (Whatever you like to Do)

    you see I don't Pick any Trop by Variables or IID

    If you don't want to use Containers and you prefer Picking by Variables I recommend the simplest method and secure by storing the UIDs on an "Instance Variable"

    Create an instance Variable on Arrow, Example lets call it "Parent" as a variable Type a Number so you will do

    On start of Layout:

    For Each Troop:>>>>Action: Create Arrow >>>>Arrow Set "Parent" to Troop UID

    Now you have linked them and if you need to Pick Arrow linked to a Troop you Do

    Pick Troop By (Whatever Method you like)

    Second Condition: Arrow.Parent = Troop UID >>>>>> Do your Actions

    That's it

    Picking by Nth they way you do is gonna give only troubles, Read Tutorials as I advise you they don't take long to finish them

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

    I see what you mean

  • Try Construct 3

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

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

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

    No problem mate

    I solved the double tap issue!!!

    Glad you manage to solved

    Issue:

    -I hope you don't rely too much on that (Event 2) as it doesn't look right :)

    -Event 5 is not gonna Work either

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)