Creating a Game Of Checkers

Hi guys,

First of all i am a newbie of Corona and non-programmer. I read your discussions & corona’s resources carefully. So i decided to make a game of checkers. i did some basic stuff like background image drag and drop image etc.

I just need your help to correct the code purged. For example,

i have StartDrag functionality copied and reedited from Corona’s example code of “Drag Platform”. Can you tell me what is unnecssary on this code as physics i try to make a simple drag and drop 2d overhead object game … Please help me to eliminate. Thank you!

Here is the code

  
local physics = require("physics")  
physics.start()  
display.setStatusBar( display.HiddenStatusBar )  
  
-- A basic function for dragging physics objects  
local function startDrag( event )  
 local t = event.target  
  
 local phase = event.phase  
 if "began" == phase then  
 display.getCurrentStage():setFocus( t )  
 t.isFocus = true  
  
 -- Store initial position  
 t.x0 = event.x - t.x  
 t.y0 = event.y - t.y  
  
 -- Make body type temporarily "kinematic" (to avoid gravitional forces)  
 event.target.bodyType = "kinematic"  
  
 -- Stop current motion, if any  
 event.target:setLinearVelocity( 0, 0 )  
 event.target.angularVelocity = 0  
  
 elseif t.isFocus then  
 if "moved" == phase then  
 t.x = event.x - t.x0  
 t.y = event.y - t.y0  
  
 elseif "ended" == phase or "cancelled" == phase then  
 display.getCurrentStage():setFocus( nil )  
 t.isFocus = false  
  
 -- Switch body type back to "dynamic", unless we've marked this sprite as a platform  
 if ( not event.target.isPlatform ) then  
 event.target.bodyType = "dynamic"  
 end  
  
 end  
 end  
  
 -- Stop further propagation of touch event!  
 return true  
end  
local background = display.newImage( "game-board.png", true )  
background.x = display.contentWidth / 2  
background.y = display.contentHeight / 2  
  
local piyon1 = display.newImage( "piyon.png" )  
piyon1.x = 80; piyon1.y = 200  
physics.addBody( piyon1, "kinematic", { friction=0.7 } )  
piyon1.isPlatform = true -- custom flag, used in drag function above  
  
-- Add touch event listeners to objects  
piyon1:addEventListener( "touch", startDrag )  

Best Regards,
Ilker OGUZ [import]uid: 34788 topic_id: 7870 reply_id: 307870[/import]

maybe the Interface/DragMe demo included would be a simpler starting point? [import]uid: 6645 topic_id: 7870 reply_id: 28012[/import]