Pixel-perfect actor placement in scene
double3
Member Posts: 3
I'm working on a game with a unique pixelated design that requires pixel-perfect placement of each actor in the scene. Dragging actors into the scene is a nightmare in this scenario. Sure, I can edit each individual actor to have an exact pixel position ... but that's very time-consuming. Since GameSalad shockingly does not have a snap-to-grid option, I'm sorta stuck. To the point that I'm seriously considering switching to a different tool like Stencyl. But before I make that drastic move ... I'm wondering if anyone can offer any tips or tricks. Or even better ... a sample file I can download and study.
I'm wondering if this can be done with tables where the table tells each actor where to place itself in the scene. Think of it this way ... say you have 100 32px blocks that you want to appear on the scene with no gaps or overlaps as they sit next to each other. Right now I'm forced to drag each of those 100 blocks into the scene and edit each one to have a perfect position. And I'm about to go nuts doing that. ???
Any help would be REALLY appreciated.
I'm wondering if this can be done with tables where the table tells each actor where to place itself in the scene. Think of it this way ... say you have 100 32px blocks that you want to appear on the scene with no gaps or overlaps as they sit next to each other. Right now I'm forced to drag each of those 100 blocks into the scene and edit each one to have a perfect position. And I'm about to go nuts doing that. ???
Any help would be REALLY appreciated.
Comments
New to GameSalad? (FAQs) | Tutorials | Templates | Greenleaf Games | Educator & Certified GameSalad User
If you don't want to use a spawner (see attached demo) and prefer to drag the actors near their final positions, you can use a snap-to-grid behavior:
Change Attribute self.position.X to floor(self.position.X/32)*32+16
New to GameSalad? (FAQs) | Tutorials | Templates | Greenleaf Games | Educator & Certified GameSalad User
I'm creating an endless runner with 8-bit pixel-perfect assets. I've got two issues with pixel perfect placement.
As in pretty much any endless runner, the actor needs to jump to avoid death.
1. During jumping, is there any way to make GS render the actor only on integer coordinates, so the actor is all sharp throughout?
2. More importantly -- I'm using gravity to bring the actor back down after the jump. But when the actor does land, he isn't sharp, because the collision system isn't that perfect, I guess (the ground actor is on an integer coordinate). Is there a way around this? Even if it means turning off the collision. Is there a way to for example set a certain coordinate as 'ground' for the actor to stop?
Thanks a lot!
floor(self.position.Y)+floor((((self.position.Y)*10-(floor(self.position.Y)*10))*2)/10)*10
edit: Ack! It doesn't work... back to the drawing board
I believe the answer is prec(self.position.Y,0)
I'm sure someone like @RThurman or @Socks can simplify that down quite a bit so I'll just leave that there. :-/
New to GameSalad? (FAQs) | Tutorials | Templates | Greenleaf Games | Educator & Certified GameSalad User
floor(self.Position.Y)+floor((self.Position.Y*10-(floor(self.Position.Y)*10))/5)
phew.
And just so I don't feel my whole morning was wasted, here's a demo with snap-to-pixel. Drag the actor and then release to snap to rounded pixels using the formula above.
New to GameSalad? (FAQs) | Tutorials | Templates | Greenleaf Games | Educator & Certified GameSalad User
The precision function is the way to quickly round up and down. But you need to be careful about rounding at the midpoint. For example prec(111.499999,0) rounds down to 111 but prec(111.5,0) rounds up to 112.
But aren't your choices to round down at 111.5 or up at 111.5? What difference does it make which way you choose? For example, 111.0 to 111.49 is a range of .49 while 111.5 to 111.99 is also a range of .49 so it seems like a toss-up.
Prec() works the way I expect it to, which is to say that it rounds up at 111.5.
New to GameSalad? (FAQs) | Tutorials | Templates | Greenleaf Games | Educator & Certified GameSalad User
Carry on!
)
Careful, you don't want to get detention from tatiang.
New to GameSalad? (FAQs) | Tutorials | Templates | Greenleaf Games | Educator & Certified GameSalad User