Collision with box()



  • ok so i was testing in the bullet board and i was trying change the place of it and size i have individual borders but it is hard to put them in the place i want without small pixel gaps so i came with the idea of can make the box() command as the border since it can be more easily moved and changed and can be hollow so im just trying to figure out if is even posible make collisions with the box() command to work like a border if it isn't possible i guess i will need to make with my wall with anoying small pixel gaps and time to correct them :P (thanks if possible in advance)


  • Fuze Team

    what are you trying to collide with box? I mean, if you're asking if there is collision detection between shape primitives (box) and sprites then the answer is no. But of course you can work out collisions with anything if you know the co-ordinates of the object you're colliding against and whatever it is you're controlling.


  • F

    What I do in Jetpac is to make a sprite but not give it an image, rather - just a width and height. Then, I just use the position of it for drawing my character image frames - it's a lot faster than continually changing the sprite image manually (as the movement is based on screen location, so doesn't suit normal sprite behaviour). In doing this, I can then still use sprite detection - although note, you can't show the sprite boundaries without an image being written - so you might want to assign "something" to it to ensure it's in the correct place.



  • You could also create an image using createImage, and then draw the box on that image with use of setDrawTarget. Then you could set that as the sprite image with setSpriteImage. Just make sure you use freeImage before replacing an existing image, if you constantly replace the sprite image with a new one that has the box.

    With createImage, you'd want to use image_rgba in stead of image_rgb so that you can still have a hollow box. Also before drawing on the image, I think you'd need to clear it. I'm not sure if you need to use a transparent color for that or not, if so, you could probably use clear({})



  • Ok i will check that out and test if i can do the bullet board (enemy turn) and the dialog/menu(player turn) with that but idk if i could just colide with a location lets say like corners x 50 and 100 and y 4 and 36 so i could collide with the location itself instead of the box()


Log in to reply