Hundreds of features to explore
Games made in Construct
Your questions answered
Trusted by schools and universities worldwide
Free education resources to use in the classroom
Students do not need accounts with us
What we believe
We are in this together
World class complete documentation
Official and community submitted guides
Learn and share with other game developers
Upload and play games from the Construct community
Game development stories & opinions
Ok, so in my game I'm working on I have snap to grid enabled. But what I want is when you mouse click it spawns a block/item in, but I want that block/item to snap to the grid so it is kinda in line with other blocks in the background.
Any info/help appreciated!
Sprite; > Set X to : (round(Sprite.X*0.05))*20 > Set Y to : (round(Sprite.Y*0.05))*20
Sprite;
> Set X to : (round(Sprite.X*0.05))*20
> Set Y to : (round(Sprite.Y*0.05))*20
i hope this helps
Yes!
I remember doing that at one point (The flashdrive I had my game saved to corrupted a few months back, and I just recently found a version of my game that was missing some stuff but could start again)
I also have a Mouse.X and Mouse.Y to spawn the item/block to where your mouse is, but how could I add the rounding function in with it?
Urmumphat LLC The same way:
Create Sprite at x=(round(Mouse.x/20)*20), y=(round(Mouse.y/20)*20)
I tried that which creates the item but doesn't round its position. My grid size is 150, but I don't think that is a factor.
Develop games in your browser. Powerful, performant & highly capable.
how large are the tiles on your grid?
150x150
ok, if each tile is 150X150
I made a demo project and tested it and it works just fine
x=(round(Mouse.x/150)*150), y=(round(Mouse.y/150)*150)
I can Link to the project if you want
If you want to create objects in the middle of each cell, add half of the cell width:
x=(round(Mouse.x/150)*150+75)
y=(round(Mouse.y/150)*150+75)
If you want to create objects in the middle of each cell, add half of the cell width: x=(round(Mouse.x/150)*150+75) y=(round(Mouse.y/150)*150+75)
I just tested this and it is very inconsistent.
The tiles either:
I dont know if it was something I did, or thats just broken lol.
THANK YOU GUYS so much!!!!!
Works flawless, feel so much better now!