How do I compare two tiles

Just started using Construct 2? Post your questions here

Post » Mon Mar 07, 2016 12:19 am

Hi guys,
I am a begginer to construct 2 . In the below image there are 4 tiles.when i drag first tile over second tile ,the numbers in 1st and 2nd tile should be changed and also the colors..
Image Image

how to do this ? ...
and next thing i want to know is

Image Image

when i tap a tile it should change both its numer and color..they sould be predefined ... i.e each tile has three set of number and colors and when the user taps it should change to second set ,when they tap for third time it should change into third set and if they tap for 4th time i should again change to 1t set...

somebody please tell me how to do these things in construct
B
6
S
1
Posts: 13
Reputation: 376

Post » Tue Mar 08, 2016 12:42 am

someone please tell me solution
B
6
S
1
Posts: 13
Reputation: 376

Post » Tue Mar 08, 2016 2:05 am

Well, there are a lot of things you asked to know how to do there, and a lot of parts to each of those things. Without knowing how far you've gotten on each part, you're basically asking someone to make your game for you. It would help a lot if you made an effort to try it on your own and ask a specific questions where you got stuck. If you upload an example of what you've got so far, it would also help in seeing what type of advice to give to you by showing your level.

Otherwise... to start - I would use one sprite object for the tiles. Each animation frame should be a different color and value. The animation frame number can be the same as the value on the tile, so when you have two overlapping, you can add both tile's animation frame numbers to get your new number.

Actually before that you probably want to figure out how to drag tiles around.

So again, what are you stuck on?
Mistakes were made.
B
51
S
25
G
107
Posts: 1,581
Reputation: 60,458

Post » Tue Mar 08, 2016 9:51 am

Yeah-- pretty loaded question, I'm guilty of doing the same thing as far as not forming the right or specific question. Here are my 1st thoughts--
How many Sprite objects do you have? Meaning I would have Sprites that have different colors programmed in the animation, then set conditions to change those colors.
Are you pining text objects? I would then pin text objects to sprites. Make some visable and in-visible, and set conditions to have them change states.

Was this helpful?
B
16
S
6
G
2
Posts: 165
Reputation: 3,209

Post » Tue Mar 08, 2016 3:18 pm

Message: karthikraja34 can only post plain text URLS until they have 500 rep. 1 URLS modified. Why?
As i said i am a beginner so i dont know much about creating events...sorry for inconvinience,but i have to submit a project within a week so please bear with me ..i need just some hints or tips on complex functions ,i can see through web for common functions....

The below link is the capx file

http://bit.ly/1ntMMLs

I want to change the first two tiles to green when the user drags first tile over second or second over first.
how to do that ?
P.S i can change both to green by using conditions but dont know how to make a smooth drag and dont cosider those numbers in the first pic(on my first post).

NOTE : the word "drag" is not appropriate...it would be better if someone tells me how to use swipe from one tile to another.
B
6
S
1
Posts: 13
Reputation: 376

Post » Tue Mar 08, 2016 8:16 pm

OK couple more pieces of advice:

I highly do not recommend using a program you are unfamiliar with to meet a time sensitive deadline.

If you are new to Construct, try to avoid using plugins. You can do almost everything with what is included in Construct, and it will be significantly harder to get help on the forums if you use a bunch of plugins. People won't be able to open your file if they don't have the same plugins installed, and few people will go out of their way to install them to help you.

Now about your project:

Will each number always be tied to the same color? In that case, you should just draw the number as part of the sprite instead of using a text object.

I see three main things you need to work on.

First is preparing your tiles. As I suggested, you should create a single sprite object containing all of your tiles, with each number corresponding to the same animation frame. Set the origin point to the center.

Second is moving the tiles. You mentioned dragging and swiping. These are two rather different things. Dragging would be relatively easy, while swiping could be rather hard. For dragging, you'll need to add a few instance variables to the sprite: boolean called Active, as well as an OriginXVariable and OriginYVariable to return the sprite back to its original position:
Code: Select all
On touched TileSprite | Set OriginXVariable to Self.X
                      | Set OriginYVariable to Self.Y
                      | Set Active to True

TileSprite Active is True  |  TileSprite Set position to Touch.X, Touch.Y

On touch release     | Move TileSprite to OriginXVariable, OriginYVariable
TileSprite is Active | Set Active to False


Third will be changing the tiles. You need to detect which two tiles are to be interacting (just using overlap will not work, as a tile can overlap several at the same time). Then you will change both tiles to the sum of their numbers/animation frame.

Out of time for now, I'll be back with the third part later if you can't figure it out.
Mistakes were made.
B
51
S
25
G
107
Posts: 1,581
Reputation: 60,458

Post » Wed Mar 09, 2016 3:15 am

For the third part you'll want a global variable called Total, to add up the two animation frames.

Code: Select all
Touch - On touch release       | Add TileSprite.AnimationFrame to Total
Touch - Is touching TileSprite |
System - For Each TileSprite   |

(Make a separate event)

Touch - On touch release       |Set TileSprite.AnimationFrame to Total
Touch - Is touching TileSprite | Set Total to 0

Mistakes were made.
B
51
S
25
G
107
Posts: 1,581
Reputation: 60,458

Post » Wed Mar 09, 2016 1:59 pm

Thanks for your help...I tried the code you have written
I have two doubts
1.
On touch release | Move TileSprite to OriginXVariable, OriginYVariable

i couldnt use the above code...it shows only pixel values
Image

2.On the previous capx (included in above reply) i made four sprites and included 3 animation frames to each tiles
and created four evens to make those tile change their color when tapped ....how to get these effect(to change only 3 different color on each tile in that square) by using single sprite (Tilesprite).
B
6
S
1
Posts: 13
Reputation: 376

Post » Wed Mar 09, 2016 6:10 pm

Sorry those should be Self.OriginXVariable and Self.OriginYVariable.

For changing on tap, you can use sub events on the Touch - On tapped TileSprite condition, then compare values.

Code: Select all
Touch - On tapped TileSprite
       
         System - Compare two values - TileSprite.AnimationFrame = 4 | TileSprite Set Animation Frame to 7
         System - Compare two values - TileSprite.AnimationFrame = 7 | TileSprite Set Animation Frame to 11
         System - Compare two values - TileSprite.AnimationFrame = 11 | TileSprite Set Animation Frame to 4
Mistakes were made.
B
51
S
25
G
107
Posts: 1,581
Reputation: 60,458

Post » Wed Mar 16, 2016 2:19 pm

Message: karthikraja34 can only post plain text URLS until they have 500 rep. 1 URLS modified. Why?
I got another one week time to complete my project. I implemented swipe function but now i m struck.

http://bit.ly/1R2TLDx

the above link is the capx file.i have spawned four tiles using a single sprite and in each tile i displayed animation frame (0,3,6,9).
i have totally 11 frames in tht sprite. when i tap the first tile it should change to next frame,on next tap on t1(tile 1) it should change to next frame but it shouldn't exceed frame 3...after frame it should start from frame 1...like that for tile 2 frames (should b 3,4,5) ;tile 3=(f 6,7,8);t4=(f 9,10,11)......how to do this ?

i made a pseudo code but it not working..
PSEUDO CODE
on tap gesture on block |
while(x<4) | block.color=block.color+1 //color is instance variable
if(x>3) | block.color=block.color-3
| x=0

someone tell me how to make this pseudo code work

and i have another doubt i will post it once i got this cleared ,at the same time i ll try to implement tht myself.
B
6
S
1
Posts: 13
Reputation: 376

Next

Return to Beginner's Questions

Who is online

Users browsing this forum: No registered users and 1 guest