Can I make an Action Call For a Custom ImagePoint?

Get help using Construct 2

Post » Tue Jul 16, 2013 11:15 pm

I have this action and im trying to make my grid stick to my Masks Image Point 1 but i do not know how to call for it,at the same time keeping everything that im trying to do.
Here is the action i need to have call for ImagePoint1
Instead of just my default X and Y i want to set it to my custom point selected.Is there a way?


round((Mask.X-TilesGrid.Width/2+16)/32)*32

round((Mask.Y)/32)*32-64
GMO FOOD = DEATH
B
23
S
9
G
5
Posts: 567
Reputation: 6,378

Post » Tue Jul 16, 2013 11:40 pm

You mean like using Mask.ImagePointX and Mask.ImagePointY ??

For example if it's imagepoint1 your would use Mask.ImagePointX(1) and Mask.ImagePointY(1)

Is that what you are wanting?
B
101
S
32
G
12
Posts: 1,549
Reputation: 21,993

Post » Tue Jul 16, 2013 11:56 pm

Yeah That makes more sense to me @ArcadEd
So i can replace Mask.X with Mask.ImagepointX(1) and be ok in this action right?
Also thanks for another tip
GMO FOOD = DEATH
B
23
S
9
G
5
Posts: 567
Reputation: 6,378

Post » Wed Jul 17, 2013 1:29 am

@ArcaEd That seemed to work for my grid but it also made my block creation offset.
I put my game demo in the capX for whoever knows about this to check out.
Im not sure if it is something in the expression or just a bug.
In pretty sure its my end,I just want my tiles to be created where they are supposed to be and thats within the grid.

Koolville Demo *Link Updated*

This happens On Touched Grid
       
       Create Tile At

        round((Touch.X-16)/32)*32

        round((Touch.Y-16)/32)*32RookieDev2013-07-17 01:41:56
GMO FOOD = DEATH
B
23
S
9
G
5
Posts: 567
Reputation: 6,378

Post » Wed Jul 17, 2013 2:54 am

Is the origin of your block in the center of it?

I'm not sure on your math. You are basically dividing by 32 and multiplying by 32 (those 2 offset each other). Unless I am not remembering my order of operations :).

Based on this: round((Touch.X-16)/32)*32
Lets assume Touch.X is 59

((59-16)/32)*32
((43)/32)*32
(1.34375)*32
43
B
101
S
32
G
12
Posts: 1,549
Reputation: 21,993

Post » Wed Jul 17, 2013 4:24 am

@ArcadEd My imagepoint is in the bottom corner,and i also have an image point that is in the middle of my block sprite.

Im actually pretty bad with math,I can almost see in your text that its my fault but i actually just learned about "round" yesterday

I guess my question is,If my touch position could always be different how do i make it so the block always fills the grid in a snapping fashion.

I would rather get help than leave it messed up,I have tried a good many of number combinations but like you said my math is obvious and it is horrible.
Thank you @ArcadEd RookieDev2013-07-17 05:13:04
GMO FOOD = DEATH
B
23
S
9
G
5
Posts: 567
Reputation: 6,378

Post » Wed Jul 17, 2013 5:29 am

There was a forum post about this not too long ago. If I remember where, I will post it.

If your grid area is going to be that small, I would be lazy and just make invisible sprites, and when you click on it, have it spawn the block :). Invisible sprites still register collisions, like touches and clicks.

My math isn't great either, I'll see if I can find that post.

ArcadEd2013-07-17 05:29:51
B
101
S
32
G
12
Posts: 1,549
Reputation: 21,993

Post » Wed Jul 17, 2013 5:35 am

[QUOTE=ArcadEd] There was a forum post about this not too long ago. If I remember where, I will post it.

If your grid area is going to be that small, I would be lazy and just make invisible sprites, and when you click on it, have it spawn the block :). Invisible sprites still register collisions, like touches and clicks.

My math isn't great either, I'll see if I can find that post.

[/QUOTE] Awesome i hope you find that post,I would love to learn what im doing wrong.I also think you are right when it comes to using individual sprites,I started to do that at first and then got confused when it came to connecting them together around my player so i found a different route.

Im actually curious @ArcadEd on how to make all of my single sprites snap to the grid and also have them follow/pinned to my players mask.
Thats where i got confused,and someone from the forums said to use a tiled backround but i shortly found out that there is not collision detection.
So i have been doing alot of this for nothing and its alittle depressing but hey thats Game Dev.I hope you find something tho because i came up short when seraching for Grid Based TopicsRookieDev2013-07-17 06:05:26
GMO FOOD = DEATH
B
23
S
9
G
5
Posts: 567
Reputation: 6,378

Post » Wed Jul 17, 2013 12:05 pm

I am willing to accept feedback from anyone who knows anything about this.
Thanks in advance i think this will be a helpful thread for people making games similar to mine.
GMO FOOD = DEATH
B
23
S
9
G
5
Posts: 567
Reputation: 6,378


Return to How do I....?

Who is online

Users browsing this forum: NN81, Seruza and 9 guests