Wisin Posted July 5, 2011 Share Posted July 5, 2011 Hi, i would like to know if theres a way to check if a dx image is collisioning with another dx element, example another image, thanks. Link to comment
Orange Posted July 5, 2011 Share Posted July 5, 2011 For that, everything has to be mixed in one resource. Create an object "dximage" or somewhat, and then in onClientRender, when rendering these, check if they collide and trigger an event if they do. That's all Link to comment
Deltanic Posted July 5, 2011 Share Posted July 5, 2011 But Orange, there are no functions for that. So he will have to do calculations with the positions + size, and when the second dx position is less then the previous result, they will collide. Eg: dx1 starts at x=40, and is 60 wide. dx2 starts at 90. 40+60=100, so dx2 will collide. But what if dx2 starts at x=10? Then do it vice versa; dx2 will be calculated as dx1. Link to comment
Orange Posted July 5, 2011 Share Posted July 5, 2011 I've just written how to start :> Of course, calculations are needed, and dx objects are one of the most useful solutions right now. Link to comment
karlis Posted July 5, 2011 Share Posted July 5, 2011 should work, didn't test it tough. function doesCollide(x1,y1,v1,h1,x2,y2,v2,h2) local horizontal=(x1)~=(x1+v1) or (x1>x2)~=(x1>x2+v2) local vertical=(y1)~=(y1+h1) or (y1>y2)~=(y1>y2+h2) return (horizontal and vertical) end Link to comment
Wisin Posted July 5, 2011 Author Share Posted July 5, 2011 Thanks karlis, but im not sure of how to use your function, i want to check when my character (a dx image) collides with a enemie (another dx image) and then do something (thats for later). Link to comment
karlis Posted July 5, 2011 Share Posted July 5, 2011 Thanks karlis, but im not sure of how to use your function, i want to check when my character (a dx image) collides with a enemie (another dx image) and then do something (thats for later). np first 2args is x and y cord of 1st element, then its width, then height, then same 4 for second. returns true/false however you should test it fully as well, i cant gurantee itll work. Link to comment
Wisin Posted July 5, 2011 Author Share Posted July 5, 2011 wow, thank you !! it works perfect! Link to comment
Wisin Posted July 5, 2011 Author Share Posted July 5, 2011 i have another question, is possible to check if the "character" is over "enemie" head? Link to comment
karlis Posted July 5, 2011 Share Posted July 5, 2011 you need to define how big is head's dimensions and call func with that. Link to comment
Wisin Posted July 5, 2011 Author Share Posted July 5, 2011 im not sure of understand correctly, what do you mean? Link to comment
karlis Posted July 5, 2011 Share Posted July 5, 2011 find the cords where the head is located, and call func with them. Link to comment
Wisin Posted July 6, 2011 Author Share Posted July 6, 2011 i have another question, is there a way to check if im over another DX element (a image)? im making platform mini game that requires this, if someone could tell me i would appreciate it. Link to comment
qaisjp Posted July 6, 2011 Share Posted July 6, 2011 Are you making "Mario returns to San Andreas!" game? Link to comment
Wisin Posted July 6, 2011 Author Share Posted July 6, 2011 no, is not "Mario", is another kind of game. Link to comment
Orange Posted July 6, 2011 Share Posted July 6, 2011 Huh, I remember that I was creating a game like that for my race server :> People could play mario on a "psp" ingame Link to comment
Deltanic Posted July 6, 2011 Share Posted July 6, 2011 Lol, offtopicers See The-kid's IWTG gamemode, that's a pretty nice 2d mode. Wishin: when 'over'? You mean with your mouse? If so, let me make some simple functions which you can expand. Link to comment
Castillo Posted July 6, 2011 Share Posted July 6, 2011 Remi-X, I think he want's to check whenver is his character image over another static image or something like that. Link to comment
Deltanic Posted July 6, 2011 Share Posted July 6, 2011 In that case he just asks the same question again, as karlis already posted a script for him to do such. Link to comment
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now