local ui= require(“ui”);
local physics = require “physics”;
local mRand = math.random;
local aCustomer={};
local aCustomerStartCircle= {};
local aCustomerEndCircle={};
local mouseStatusFlag=0;
local numberOfCustomer=3;
display.setStatusBar( display.HiddenStatusBar );
print( display.viewableContentHeight )
print( display.viewableContentWidth )
function onTouch(event)
local t=event.target;
if event.phase == “began” then
print(“Touch Began Event Fired…”);
local parent =t.parent;
parent:insert(t);
display.getCurrentStage():setFocus( t )
event.target.alpha = 0.5;
t.isFocus=true;
t.X0=t.x;
t.Y0=t.y;
elseif t.isFocus then
if “moved” == event.phase then
t.x = event.x;
t.y = event.y;
elseif event.phase== “ended” or event.phase == “cancelled” then
print(“Touch Ended Event Fired…”);
event.target.alpha = 1;
display.getCurrentStage():setFocus(nil);
t.isFocus = false
end
end
return true;
end
function Customer_StartPoint(number_of_Points)
local pointX=50;
local pointY=50;
local radiusZ=20;
for i=1, number_of_Points do
local customer_point=display.newCircle(pointX,pointY,radiusZ);
customer_point.strokeWidth=3;
customer_point:setFillColor(mRand(0,255),mRand(0,255),mRand(0,255));
customer_point:setStrokeColor(255,255,255);
print(customer_point.x…" "…customer_point.y);
aCustomerStartCircle[i]=customer_point;
pointY =pointY + 70;
end
end
function Customer_EndPoint(number_of_Points)
local pointX=250;
local pointY=250;
local radiusZ=20;
for i=1, number_of_Points do
local customer_point=display.newCircle(pointX,pointY,radiusZ);
customer_point.strokeWidth=5;
customer_point:setFillColor(mRand(0,255),mRand(0,255),mRand(0,255));
customer_point:setStrokeColor(255,255,255);
customer_point.isFilled = false;
customer_point.myName=“EndCircle”;
customer_point.id=i;
physics.addBody(customer_point,“static”);
aCustomerEndCircle[i]=customer_point;
pointY =pointY + 70;
end
end
function start_Method(number_of_Element)
local pointX=50;
local pointY=40;
for i=1, numberOfCustomer do
pictName = “custm.png”;
img=display.newImage(pictName,pointX,pointY);
img.X=pointX;
img.Y=pointY;
img.id=i;
physics.addBody(img,“static”);
img:addEventListener(“touch”,onTouch);
aCustomer[i]=img;
pointY =pointY + 70;
end
end
function main_function()
physics.start();
Customer_StartPoint(numberOfCustomer);
start_Method(numberOfCustomer);
Customer_EndPoint(numberOfCustomer);
end
function onCollisionWith (event )
print(“Enter In Collision…”);
end
main_function();
Runtime:addEventListener( “collision”,onCollisionWith);
In above program i m trying to detect collision between customer and the customer End point circle …but not able to do this… can anyone suggest me why it not fire the collision method… [import]uid: 42177 topic_id: 8114 reply_id: 308114[/import]