Page 1 of 1

if(CollisionFree("TILES" ,x - 2,y) == false) x -= 0;

PostPosted: Tue Feb 05, 2008 5:23 pm
by equinox
Hi at all,

I dont undestand the "if(CollisionFree(....)",,

In my code-->

in script editor-->MAN--> press S for left
{
if(CollisionFree("TILES" ,x - 2,y) == false) x -= 0;
}

I wish that the my MEN collides always with the ACTORS i created--> TILES and when collides the MEN stop...but my code dosent work.

PLEASE: someone can help me with my code?

Tnk1000.

...

PostPosted: Wed Feb 06, 2008 5:47 pm
by DarkParadox
collisionfree function can NOT used in a if function.
collisionfree is made to MAKE the actor collide or stop colliding with the corrisponding actor(the actor you set in the function)
or you might want to try(!this may not work![untested]!!)

if(CollisionFree("TILES" ,x - 2,y) == 0) x -= 0;
instead of:
if(CollisionFree("TILES" ,x - 2,y) == false) x -= 0;
P.S.
use 1 for true

Re: ...

PostPosted: Wed Feb 06, 2008 5:55 pm
by makslane
diormeh wrote:collisionfree function can NOT used in a if function


Read here:
http://game-editor.com/docs/script_refe ... lisionfree

Re: if(CollisionFree("TILES" ,x - 2,y) == false) x -= 0;

PostPosted: Wed Feb 06, 2008 7:27 pm
by equinox
Hi diormeh ,

Tnk for reply, but your code not work.

Re: if(CollisionFree("TILES" ,x - 2,y) == false) x -= 0;

PostPosted: Wed Feb 06, 2008 7:29 pm
by DarkParadox
sorry bout that,(i was wrong)
ya i found something in the script reference you might like:

CollisionFree: Check if position (x, y) is collision free for ActorName. Return 1 if not collide, 0 otherwise.
int CollisionFree(char *actorName, int x, int y)
Actor name:
- "Event Actor": Actor that is receiving the current event.
- "Parent Actor": Event Actor's parent, if exists.
- "Creator Actor": Event Actor's creator, if Event Actor has been created in some "Create Actor" action.
- "Collide Actor": Actor that collided with the event Actor.
- Any Actor in game.

Script Editor Syntax:
if (CollisionFree("Event Actor", x, y+5)) y=y+5; //On KeyDown Event script for KEY_DOWN, check if there is no collision before moving an actor down by 5 pixels.