editing the properties of an image

hi,can anyone suggest me any third party software than i can use to edit an image like this.,so that when an object collide with the black portion of the image it prints “collided”,

local image=display.newImageRect(“plus.png”,300,300)

image.x=display.contentWidth*0.5;

image.y=display.contentHeight*0.5;

actually,what happen is when i drag another object close to it.it prints “collided”.

so is there any software that can help me in editing the image properties for collission detection.

There are multiple possibilities. Consider:

Physics Editor: https://www.codeandweb.com/physicseditor

Physics Body Editor: http://www.aurelienribon.com/blog/projects/physics-body-editor/ (and there is a plugin that helps it work with Corona https://store.coronalabs.com

thank you :slight_smile:

thank you for the advice,i used physics editor for editing the image.

my earlier code was something like this

–game1.lua-------------------------------------------(how i coded earlier)

local storyboard=require(“storyboard”)

local scene=require(“scene”)

function scene:createScene(event)

local screenGroup=self.view

local image=display.newImageRect(“plus.png”,300,300)

image.x=display.contentWidth*0.5;

image.y=display.contentHeight*0.5;

screenGroup:insert(image);

end

function scene:enterScene(event)

end

function scene:exitScene(event)

end

function scene:destroyScene(event)

end

scene:addEventListener(“createScene”,scene);

scene:addEventListener(“enterScene”,scene);

scene:addEventListener(“exitScene”,scene);

scene:addEventListener(“destroyScene”,scene);

return scene;


after using physics editor it created a .lua file of the image and i named it plus.lua


i am having a doubt here.how do i use this plus.lua file in my earlier code???

local scaleFactor = 1 local physicsData = (require "plus").physicsData(scaleFactor) ... -- create your plus sign like you normally do ... physics.addBody( image, "dynamic", physicsData:get("plus"))

There are a lot of assumptions in there:

  1. you used a 1x image to draw the physics. If you used an @2x image or @4x image, you will have to adjust the scaleFactor to 0.5 or 0.25

  2. your image used is named “plus” inside of the PE code.

But something similar should get you working!

thank you for helping;

it worked for a normal plus image like

physics.setDrawMode(“hybrid”)

local physicsData = (require (“plus”)).physicsData(1,1);

plus=display.newImageRect(“plus.png”,100,100);

plus.x=100;

plus.y=500;

physics.addBody(plus, “static”,physicsData:get(“plus”));


but when i change the size of image to something like

local physicsData = (require (“plus”)).physicsData(1,1);

plus=display.newImageRect(“plus.png”,100,250);

plus.x=100;

plus.y=500;

physics.addBody(plus, “static”,physicsData:get(“plus”));


how can we corrent it?

You will have to make another physic lua file. Since you you are changing the aspect ratio.

ohh…okay,thank you

There are multiple possibilities. Consider:

Physics Editor: https://www.codeandweb.com/physicseditor

Physics Body Editor: http://www.aurelienribon.com/blog/projects/physics-body-editor/ (and there is a plugin that helps it work with Corona https://store.coronalabs.com

thank you :slight_smile:

thank you for the advice,i used physics editor for editing the image.

my earlier code was something like this

–game1.lua-------------------------------------------(how i coded earlier)

local storyboard=require(“storyboard”)

local scene=require(“scene”)

function scene:createScene(event)

local screenGroup=self.view

local image=display.newImageRect(“plus.png”,300,300)

image.x=display.contentWidth*0.5;

image.y=display.contentHeight*0.5;

screenGroup:insert(image);

end

function scene:enterScene(event)

end

function scene:exitScene(event)

end

function scene:destroyScene(event)

end

scene:addEventListener(“createScene”,scene);

scene:addEventListener(“enterScene”,scene);

scene:addEventListener(“exitScene”,scene);

scene:addEventListener(“destroyScene”,scene);

return scene;


after using physics editor it created a .lua file of the image and i named it plus.lua


i am having a doubt here.how do i use this plus.lua file in my earlier code???

local scaleFactor = 1 local physicsData = (require "plus").physicsData(scaleFactor) ... -- create your plus sign like you normally do ... physics.addBody( image, "dynamic", physicsData:get("plus"))

There are a lot of assumptions in there:

  1. you used a 1x image to draw the physics. If you used an @2x image or @4x image, you will have to adjust the scaleFactor to 0.5 or 0.25

  2. your image used is named “plus” inside of the PE code.

But something similar should get you working!

thank you for helping;

it worked for a normal plus image like

physics.setDrawMode(“hybrid”)

local physicsData = (require (“plus”)).physicsData(1,1);

plus=display.newImageRect(“plus.png”,100,100);

plus.x=100;

plus.y=500;

physics.addBody(plus, “static”,physicsData:get(“plus”));


but when i change the size of image to something like

local physicsData = (require (“plus”)).physicsData(1,1);

plus=display.newImageRect(“plus.png”,100,250);

plus.x=100;

plus.y=500;

physics.addBody(plus, “static”,physicsData:get(“plus”));


how can we corrent it?

You will have to make another physic lua file. Since you you are changing the aspect ratio.

ohh…okay,thank you