Feedback wanted

Hi Andrew

Thanks! That would add some logic to the accessing, if i want to implement this in a loop would i then need to make something like:
if i = 1 (or whatever number) then
Add to this display group
if i = 2 then
Add to that display group

Or is there a better way to add each loop to a different group?

Bram

Hi Bram,

Typically, you never want to code something that’s not “scalable”.  Your approach of if i==1 do something, i==2 do something else, etc. would not be scalable if the possible values for i were large – you’d be writing a lot of code that’s effectively doing the same thing.  Instead, you’d want to set up an array of display groups (using a table) and insert into the i’th element of the array.

  • Andrew

Hi Andrew,

Thanks for all the help!

I sort of have it working, i can refer to the corner by using “cornerGroup[4].alpha = 1”

The corner group contains all the corners and corners have 4 “directions” like:

local topLeft = polygonFill( table.listToNamed(tlcPoints,{'x','y'}), isclosed, isperpixel, widthheight, widthheight, {0,0,0} ) corner:insert( topLeft ) local topRight = polygonFill( table.listToNamed(trcPoints,{'x','y'}), isclosed, isperpixel, widthheight, widthheight, {0,0,0} ) corner:insert( topRight ) local bottomLeft = polygonFill( table.listToNamed(blcPoints,{'x','y'}), isclosed, isperpixel, widthheight, widthheight, {0,0,0} ) corner:insert( bottomLeft ) local bottomRight = polygonFill( table.listToNamed(brcPoints,{'x','y'}), isclosed, isperpixel, widthheight, widthheight, {0,0,0} ) corner:insert( bottomRight ) cornerGroup:insert( corner )

What i think is happening when i’m targeting cornerGroup[4] is that i refer to the 4th corner in the cornerGroup. But what i don’t understand is why i can’t refer to the direction e.g bottomRight by doing “cornerGroup[4].bottomLeft” ?

When i try i get the message “attempt to index field ‘bottomLeft’ (a nil value)”

It’s been a time i posted here, and for the good because the game is almost finished!

I’m now in a stage of doing thorough testing so i can deliver a solid working game when it’s published in the app store.

While testing i noticed one particular problem. When in game there are two buttons, one to go back to the main screen and the other one to ga to the next level. the switching between levels works fine. But sometimes when entering a level, the buttons won’t appear. I cant find the source of this problem but i think it’s in my “drawPrevButton()” function. This is the code:

local function drawPrevButton() x = 20 y = 65 addX, addY = 25, 25 local triangle = { x,y+(addY/2), x+addX,y, x+addX,y+addY, x,y+(addY/2) } prevButton = polygonFill( table.listToNamed(triangle,{'x','y'}), isclosed, isperpixel, widthheight, widthheight, {0,0,0} ) prevButton:addEventListener( "touch", onPrevBtnRelease ) prevButton.alpha = 1 transition.to( prevButton, { time=10, alpha=1, y=0, transition=easing.inQuad } ) end

Whats weird in this function is that when i remove the line:

transition.to( prevButton, { time=10, alpha=1, y=0, transition=easing.inQuad } )

It won’t work, even when i remove the y=0 in the transition options it won’t work. By “won’t work” i mean the button does not appear in game.

Most of the times while playing the buttons appear as they should, but sometimes they won’t. There is nothing particular i’mm doing that may cause this error so i’m kind of lost on how to fix this… 

Thanks,

Bram

Hi Bram,

The reason cornerGroup[4].bottomLeft doesn’t work (right now) is because you haven’t set up the reference that way (yet).  But we can fix that.

Let’s take this portion of your code as an example:

[lua]

local bottomLeft = polygonFill( table.listToNamed(blcPoints,{‘x’,‘y’}), isclosed, isperpixel, widthheight, widthheight, {0,0,0} )

corner:insert( bottomLeft )

[/lua]

This adds a filled polygon to the corner.  However, ‘bottomLeft’ is just a local variable used to refer to the polygon object.  The corner doesn’t ‘use’ that name other than to get a reference to the polygon object.  That’s why writing corner.bottomLeft (or cornerGroup[4].bottomLeft) won’t work.

To make it work, try this:

[lua]

local bottomLeft = polygonFill( table.listToNamed(blcPoints,{‘x’,‘y’}), isclosed, isperpixel, widthheight, widthheight, {0,0,0} )

corner:insert( bottomLeft )

corner.bottomLeft = bottomLeft

[/lua]

Now, not only are we adding bottomLeft to the group, as before, we’re also adding a custom property of the group to refer directly back to bottomLeft.  Now you should be able to write corner.bottomLeft (or cornerGroup[4].bottomLeft) to target that polygon.

Hope this helps.

  • Andrew

Hi Andrew,

Thanks for all the help!

I have working corners! But i don’t yet have a way of checking if a corner is activated twice and thus needing to “triangulate” (cant find a good translation), and to know in what direction the triangle/corner should go. Do you have any tips on how to check this?

The latest code can be found here

Many thanks and if you ever would need something be sure to let me know!

Hi Bram,

Yes, if you could explain a bit more what you mean by “triangulate”, that would be helpful.  Perhaps you could point it out in the concept video that you posted earlier?

  • Andrew

Hi Andrew,

Thanks!

What i mean is, when you touch two blocks and they intersect the corner should be stomped.

Now when i activate the cornerObject it adds an extension to the block creating a longer block.

The cornerObject holds 4 triangles, when one block is active they are all visible thus creating the extension. But when an intersection block is active only 1 of the triangles should be active creating a “stomped” corner. 

I don’t yet have a way of knowing if a block intersects en what direction the triangle should go.

By direction i mean when a horizontal block is active and a vertical block (on the right side going down). the bottomLeft triangle should be active. When the vertical block would be goin upwards the topLeft triangle should be active etc.

In the video the effect is shown on 0:22 (there is one fault in the vid though, the touched block only adds an corner to the left side. it should be on both ends, then when the intersect is created the corner would change in a triangle)

Bram

Hi Bram,

Thanks, I understand what you mean now.  To detect which triangle within the corner to show, you could compare the x,y coordinates of the corner with the x,y coordinates of the adjacent blocks?  That would be able to tell you which direction the block is in relative to the corner (e.g., if it has the same x, but the y is 1 less, than the block is above the corner).

  • Andrew

Hi Andrew, 

I have the corners working properly now, i have added the neighboring corners to the blocks by linking them in a table (simply the number they have in the corner group). And then written a massif amount of conditionals to see what kind of corner needs to be active and when. I don’t think it’s the most efficient way of doing this but it works great  ;). 

Currently i’m trying to tackle the problem of checking when all the correct blocks are active. 

Do you have any idea’s on where to start on this subject?

Many thanks!

Bram

It’s been a time i posted here, and for the good because the game is almost finished!

I’m now in a stage of doing thorough testing so i can deliver a solid working game when it’s published in the app store.

While testing i noticed one particular problem. When in game there are two buttons, one to go back to the main screen and the other one to ga to the next level. the switching between levels works fine. But sometimes when entering a level, the buttons won’t appear. I cant find the source of this problem but i think it’s in my “drawPrevButton()” function. This is the code:

local function drawPrevButton() x = 20 y = 65 addX, addY = 25, 25 local triangle = { x,y+(addY/2), x+addX,y, x+addX,y+addY, x,y+(addY/2) } prevButton = polygonFill( table.listToNamed(triangle,{'x','y'}), isclosed, isperpixel, widthheight, widthheight, {0,0,0} ) prevButton:addEventListener( "touch", onPrevBtnRelease ) prevButton.alpha = 1 transition.to( prevButton, { time=10, alpha=1, y=0, transition=easing.inQuad } ) end

Whats weird in this function is that when i remove the line:

transition.to( prevButton, { time=10, alpha=1, y=0, transition=easing.inQuad } )

It won’t work, even when i remove the y=0 in the transition options it won’t work. By “won’t work” i mean the button does not appear in game.

Most of the times while playing the buttons appear as they should, but sometimes they won’t. There is nothing particular i’mm doing that may cause this error so i’m kind of lost on how to fix this… 

Thanks,

Bram