setCollisionPolyCustom.... (Solved)
by rennie moffat · in iTorque 2D · 12/01/2010 (5:37 pm) · 0 replies
EDIT:
My apologies, I had left out negative sign in one of my collision vertexes and as a result the poly was not convex.
////original.
forgive me for asking but I am having some problems with setCollisionPolyCustom. Sometimes it works, other times like now, not so much...
Is there any perceivable reason why this would not set, when I add the behavior?
if(!isObject(objectBehavior))
{
%template = new behaviorTemplate(objectBehavior);
%template.friendlyName = "objectBehavior";
%template.behaviorType = "objectBehavior";
%template.description = "objectBehavior";
//collisionPoly
%template.addBehaviorField(edges, "", int, "4");
%template.addBehaviorField(vertex1, "", Point2F, "-0.098 -0.668");
%template.addBehaviorField(vertex2, "", Point2F, "0.447 0.658");
%template.addBehaviorField(vertex3, "", Point2F, "0.123 0.363");
%template.addBehaviorField(vertex4, "", Point2F, "-0.452 0.334");
}
///onBehaviorAdd
function greenTileBehavior::onBehaviorAdd(%this)
{
%this.owner.setCollisionPolyCustom(%this.edges, %this.vertex1, %this.vertex2, %this.vertex3, %this.vertex4);
%this.owner.setCollisionActive(false, true);
%this.owner.setPhysicsSuppress(true);
%this.owner.setCollisionCallback(true);
%this.owner.setImmovable(true);
}
[/code]
As I say, historically, sometimes this worked perfectly, others like now it won't> I don't get it. I am doing something wrong?
My apologies, I had left out negative sign in one of my collision vertexes and as a result the poly was not convex.
////original.
forgive me for asking but I am having some problems with setCollisionPolyCustom. Sometimes it works, other times like now, not so much...
Is there any perceivable reason why this would not set, when I add the behavior?
if(!isObject(objectBehavior))
{
%template = new behaviorTemplate(objectBehavior);
%template.friendlyName = "objectBehavior";
%template.behaviorType = "objectBehavior";
%template.description = "objectBehavior";
//collisionPoly
%template.addBehaviorField(edges, "", int, "4");
%template.addBehaviorField(vertex1, "", Point2F, "-0.098 -0.668");
%template.addBehaviorField(vertex2, "", Point2F, "0.447 0.658");
%template.addBehaviorField(vertex3, "", Point2F, "0.123 0.363");
%template.addBehaviorField(vertex4, "", Point2F, "-0.452 0.334");
}
///onBehaviorAdd
function greenTileBehavior::onBehaviorAdd(%this)
{
%this.owner.setCollisionPolyCustom(%this.edges, %this.vertex1, %this.vertex2, %this.vertex3, %this.vertex4);
%this.owner.setCollisionActive(false, true);
%this.owner.setPhysicsSuppress(true);
%this.owner.setCollisionCallback(true);
%this.owner.setImmovable(true);
}
[/code]
As I say, historically, sometimes this worked perfectly, others like now it won't> I don't get it. I am doing something wrong?
About the author
My thanks to Garage Games and the Garage Games Community combined with owned determination I got one game up, Temple Racer and I am looking to build more interesting, fun games for the mass market of the iOS app store.