Multiple possible tiles? Logical operators?

0 favourites
  • 13 posts
From the Asset Store
Piano tiles
$9.99 USD
Template for a piano tiles game, fully documented in comments and video
  • Is it possible to use a "|" (OR operator) to give optional returns for all these? It would really cut down on some of my events. This could also go for the "&" (AND operator).

    In other words, in the highlighted part in the image below, instead of just looking for tile "13", could I do tile "13|14|15" etc? Does anyone have experience with this? This is using the TileMap object.

  • Just did some experimentation, no go. If anyone has experience with this, please offer some advice. It would be easier than having a ton of events that all say the same thing except the tile.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • You can have a single event with all the compare tile conditions with different target tiles and right click to turn it into an OR block.

    Edit: Alternatively, you can use the System-General-Is between values condition with the tileat(x,y) condition.

  • Use loop "for" with start index = 0, end index =2. Change the value (from highlighted) into 13+loopindex

  • Your best bet is probably a function. 1st and 2nd parameters are the coordinates, and the rest are tile ID that are to be checked.

  • Thank you all for the responses, guys. I'm gonna play around with various techniques. Thanks again!

  • There definitely should be a simple way to provide multiple values to check. I've needed this in the past numerous times. Current methods aren't that satisfactory for me due to the complexity it introduces to the eventsheet. :\</p>

  • You actually can use | as an "or" operator in an expression, which returns 0 for false and 1 for true. This can be combined with system compare two values to set your condition. ref: https://www.scirra.com/manual/78/expressions

    It will reduce the number of events, but also decrease readability.

  • yeah, that's an option, but still is not adequate in my opinion.

    In my case, I just added the ability to specify multiple tiles via a string "0,1,2" to a custom Behavior (I created a behavior where I just add stuff that is missing from c2).. So now I can do it in a readable fashion. This should be made available by default though. I submitted the suggestion to their suggestion thing.

  • Include a link to your suggestion! I don't think people check that regularly at the moment, so its always good to provide the link to specific suggestions in relevant threads.

  • alright, here's the link:

    https://construct3.ideas.aha.io/ideas/C3-I-172

    and for the behavior, in-case anyone is interested:

    Cnds.prototype.CompareTilesAt = function (tx, ty, cmp, t)
    	{
    		var tile = this.inst.getTileAt(tx, ty);
    		
    		if (tile !== -1)
    			tile = (tile & TILE_ID_MASK);
    		
    		var tileArray = t.split(",");
    		var tileCmp = false;
    		for(var i=0; i<tileArray.length; i++){
    			if(cr.do_cmp(tile, cmp, parseInt(tileArray[i]))){tileCmp=true; break;}
    		}
    		
    		return tileCmp;
    	};[/code:1pyao95e]
    as far as I can tell from my own uses, it works well.
  • yeah, that's an option, but still is not adequate in my opinion.

    In my case, I just added the ability to specify multiple tiles via a string "0,1,2" to a custom Behavior (I created a behavior where I just add stuff that is missing from c2).. So now I can do it in a readable fashion. This should be made available by default though. I submitted the suggestion to their suggestion thing.

    Sorry for my absence. I've been trying to finish getting a Minecraft server up and running.

    I would love to see what you've done with your custom plugin that "adds stuff" that "should be" in C2. There are a number of little things that get me about C2 (nothing off the top of my head since I've been in java land the past few weeks) but it would be interesting to see what you got.

  • I haven't added too much, but I do have ability to set margins/edge style/fill style of 9 patches. Setting the frame duration of a sprite animation.

    I can also retrieve those values.

    I can also retrieve the imagepoint name if I give the animation/frame/point index.

    I can also retrieve the image point index if I give the animation/frame/point name.

    whenever I need some capability like those I just add it to this behavior.

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