How do I compare two tiles

Just started using Construct 2? Post your questions here

Post » Wed Mar 16, 2016 11:06 pm

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

Post » Thu Mar 17, 2016 12:23 am

karthikraja34 wrote: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.


Ok you have a few issues here. First you don't need a "While" condition- that will make the event run over and over again until the other conditions are false.

Second you don't want the x>3 as a sub event of x<4 - the sub event will only run if the parent event does - basically if x is 4, the parent event won't run, and the sub event won't either.

From there you also have a couple more problems. One is that your x global variable will cycle 0-1-2-3-4-1-2-3-4-1... ect, but this global variable will be shared for all your blocks and not each one individually.

The other problem is that Block.color as an instance variable, and doesn't actually change the color of the block or do anything at all by itself. You want Block - Set animation frame to Block.AnimationFrame+1.

Put those two together and you might realize your animation frame will keep going up no matter what your x variable is, so you'll need to rethink through your logic a bit. You probably don't need the x variable at all. I suggest having an instance variable for your block with the starting frame number.
Code: Select all
Block.AnimationFrame < Block.OriginalFrame+4 | Block - Set animation frame to Block.AnimationFrame+1
Block.AnimationFrame = Block.OriginalFrame+4 | Block - Set animation frame to Block.OriginalFrame
Last edited by oosyrag on Fri Mar 18, 2016 6:23 pm, edited 1 time in total.
Mistakes were made.
B
53
S
27
G
114
Posts: 1,699
Reputation: 64,446

Post » Thu Mar 17, 2016 1:27 pm

Message: karthikraja34 can only post plain text URLS until they have 500 rep. 1 URLS modified. Why?
I have made the changes u told....it still has two problem..
1.Only two tiles are working
2.How to set instant variable to starting frame number since each tile has to start with different frame numbers

http://bit.ly/22nqdeF

And my final doubt in this project is

When the user swipes a tile over another( or towards another tile) both tiles should change into a diiferent frame. That is after tap gesture is implemented each tile will have four frames .so how to change frames of both tiles ( one which is swipinging and another which is target or swiped into).I think the above question will have a very long code ..so tell me a basic concept or code for one tile i can manage to do for others.
B
6
S
1
Posts: 13
Reputation: 376

Post » Fri Mar 18, 2016 12:53 pm

someone help me
B
6
S
1
Posts: 13
Reputation: 376

Post » Fri Mar 18, 2016 10:13 pm

The first two problems are related - to set the origin frame, you would use the action Block - Set originalframe to Block.AnimationFrame.

The swiping was more complicated than I expected without Families (I'm assuming you're using the free version of C2), so I've put together an example with comments here (with help from R0J0hound) -

https://www.dropbox.com/s/ui33osmgp9tlq ... .capx?dl=0

The next thing to figure out would probably be how to handle looping - I've included a bit for when newcolor is higher than the amount of animation frames you have, then it will loop back by using % (modulo). I didn't add that for when you tap the colors though - so if your color tries to change to a color higher than the number of animation frames you have, it will just get stuck.
Mistakes were made.
B
53
S
27
G
114
Posts: 1,699
Reputation: 64,446

Post » Tue Mar 22, 2016 1:11 pm

Hey oosyrag there is a logical mistake in the code u have written and i dont know how to chnge it...
it was when a tile is swiped over another both the tiles should change into new color but the problem is after changing its original color the tap fuction is getting changed..
for ex

T1(0,1,2) T2( 3,4,5)
T3(6,7,8) T4( 9,10,11)


T-TILES
consider the above four as frame numbers and if T2 is swiped towards T3 (active frame in T2 is 4 and in T4 is 11)
afterwards the both are changing into new frame no (say 6).Now look below for new frames in tiles

T1(0,1,2) T2(6,7,8)
T3(6,7,8) T4(5,6,7)
well the above frames are not accurate but the thing is they are changing.And the actua frame is to be

T1(0,1,2) T2(3,6,4)
T3(6,7,8) T4(9,10,6).

how to do this?

if by any chance can u pm me i can send image to explain this (p.s i m a new member cant send pm).
B
6
S
1
Posts: 13
Reputation: 376

Post » Wed Mar 23, 2016 11:28 pm

Bump
B
6
S
1
Posts: 13
Reputation: 376

Post » Thu Mar 24, 2016 9:25 pm

Only you know how you want your logic set up exactly, and I can't make your game for you (nor am I inclined to). Try to figure out as much of the logic as you can and if you have any specific questions about why something does or doesn't work the way you expect it to, I'd be happy to help.
Mistakes were made.
B
53
S
27
G
114
Posts: 1,699
Reputation: 64,446

Post » Sun Mar 27, 2016 2:55 pm

Message: karthikraja34 can only post plain text URLS until they have 500 rep. 1 URLS modified. Why?
I have nearly completed my project ,all logics were implemented but there are two bugs....
Those two are very small bugs ,i couldn't solve them.So i hope u would help.

http://bit.ly/1LRLC8e

i have attached link for capx the bugs..
1.function is not working (i.e only function works when it has less than 3 sub events...if sub event exceeds more than 3 it is not working properly)
2.i cant set tht bullet behaviour within a box(all tiles moving outside when swiped in tht direction)

for functions i tried many methods still it works only when it has two or three sub events
and second problem i created a box and made it as solid ,but still tile moves outside it.
B
6
S
1
Posts: 13
Reputation: 376

Post » Mon Mar 28, 2016 4:29 am

https://www.dropbox.com/s/r2lgciwcvi6hi ... .capx?dl=0

Issue 1 - The added condition to the direction will let it run only if it is above, below, left, or right of the center of your boundary box.

I'm not sure I understand what you are going for your function, but remember, ELSE will only run if the event directly before it on the same level did NOT run.
It should work as all events do - The function will go through each event until it finds conditions that match, then it will run those actions in that event.
Mistakes were made.
B
53
S
27
G
114
Posts: 1,699
Reputation: 64,446

PreviousNext

Return to Beginner's Questions

Who is online

Users browsing this forum: No registered users and 2 guests