sprites not going to the edge of just the right side of the canvas

26 views
Skip to first unread message

neurodr

unread,
Jun 19, 2015, 12:43:09 PM6/19/15
to mitappinv...@googlegroups.com
I have an app where I am putting sprites on a canvas. The canvas is set to fill space for both width and height. I want the sprites fixed to the edge. In the example images you can see that at the top edge the spike sprite goes all the way to the edge. The left sprite also goes completely to the edge. The y and x values are coded as 0 respectively. For the right edge, I always get about a 1 pixel space between the sprite and the edge. See the spike rt file. Both left and right sprites are mirror images of each other, so I don't know why the space would be there. As for the coding I've tried setting the sprites position to the canvas width minus the sprite width. I've tried adding and subtracting values from that number too. I've even set the width of the canvas to a specific pixel dimension and then placed the sprite on the right at that width and still have the space. I don't have this problem for the bottom sprite that I code using the same formula just using height instead of width. The canvas is only bounded by the screen. It is not in any other container, though I have tried doing that, but still have the same problem. Any thoughts on what could be happening and how to fix it? Thanks.
spike rt.png
canvas 1.jpg
spike lft.png
blocks.png

Taifun

unread,
Jun 19, 2015, 12:51:44 PM6/19/15
to mitappinv...@googlegroups.com
the size of your sprite is 175x175 px, which means, there is a transparent border around of the sprite... try to cut the sprite and remove all the transparent border
Taifun

neurodr

unread,
Jun 19, 2015, 4:44:11 PM6/19/15
to mitappinv...@googlegroups.com
  I don't understand where the 175x175 number comes from. The images I posted initially are just screen shots of my sprites. My actual sprites do not have a border and are set to 230x68 (w x h): see attached. In my app they are re-sized to 35x15. The exact same sprite, but rotated, are properly placed on the left side of the screen which makes this even more confusing for me. I just tried a sprite that was just a solid colored background and I still have the space. attached

l1spikeright.png
spike test.png

neurodr

unread,
Jun 19, 2015, 7:53:39 PM6/19/15
to mitappinv...@googlegroups.com
After a lot of testing it looks like the sprite width had to be an even number. Everything was displaying properly when I resized my sprites to 36 instead of 35???? 72 worked as did 30. My sprite width had to be set to automatic as well. I didn't test whether changing them to an even number in the sprite design area worked, so that could be a possibility. update: just checks and simply changing the width to 36 from 36 solved the problem too.
Reply all
Reply to author
Forward
0 new messages