Put a line under an other object

Hi !

I recently got into Corona and I have to say that it’s very very interesting.

But, I have a little problem :

I’m trying to put a line (display.newLine()) under a Image (display.newImageRect()) but I can’t do it.

I need your help, I’ll be greatful for any answer.

(PS: Sorry for bad english, i’m french).

Hi @Mohamed-Ch30,

Welcome to Corona! Can you please post the code you’re currently using to do this? Remember to please surround the code with “lua” tags for clarity here in the forum thread:

[lua] -- Your code [/lua]

Thanks,
Brent

Hello, I made a mistake :

I’ve forgotted that we can make group to insert object in there,

So I’ve tried with the group and It worked !

Sorry for the useless topic.

By the way, here is the code :

[lua]

---------- Graphic Representation trying to make a Curve ----------

local background = display.newImageRect(  “Background.png”, 1280, 720)

background.x = display.contentCenterX

background.y = display.contentCenterY

local upTop = display.newImageRect(“testTop.png”, 720, 164)

upTop.x = display.contentCenterX

upTop.y = display.contentCenterY

upTop.rotation = 270

local group = display.newGroup()

local star = display.newLine( 1280, 90, 1280, 90 )

star.strokeWidth = 8

local star2 = display.newLine( 1285, 95, 1285, 95 )

star2.strokeWidth = 8

star2:setStrokeColor( 1, 1, 1, 0.3 )

group:insert(background)

group:insert(star)

group:insert(star2)

group:insert(upTop)

local number = 1

function addNewLine()

  varNum = math.random (50, 700)

  varX = (1280 + 5*number)

  varY = varNum

  varY2 = varY+5

  star:append(varX, varY)

  star2:append(varX+5, varY2)

  local simpleTransition = transition.to( star, {time = 600, x = star.x - 50} )

  local simpleTransition = transition.to( star2, {time = 600, x = star2.x - 50} )

  number = number + 1

end

timer.performWithDelay( 500, addNewLine , -1 )

[/lua]

Thanks for the answer.

Hi @Mohamed-Ch30,

Welcome to Corona! Can you please post the code you’re currently using to do this? Remember to please surround the code with “lua” tags for clarity here in the forum thread:

[lua] -- Your code [/lua]

Thanks,
Brent

Hello, I made a mistake :

I’ve forgotted that we can make group to insert object in there,

So I’ve tried with the group and It worked !

Sorry for the useless topic.

By the way, here is the code :

[lua]

---------- Graphic Representation trying to make a Curve ----------

local background = display.newImageRect(  “Background.png”, 1280, 720)

background.x = display.contentCenterX

background.y = display.contentCenterY

local upTop = display.newImageRect(“testTop.png”, 720, 164)

upTop.x = display.contentCenterX

upTop.y = display.contentCenterY

upTop.rotation = 270

local group = display.newGroup()

local star = display.newLine( 1280, 90, 1280, 90 )

star.strokeWidth = 8

local star2 = display.newLine( 1285, 95, 1285, 95 )

star2.strokeWidth = 8

star2:setStrokeColor( 1, 1, 1, 0.3 )

group:insert(background)

group:insert(star)

group:insert(star2)

group:insert(upTop)

local number = 1

function addNewLine()

  varNum = math.random (50, 700)

  varX = (1280 + 5*number)

  varY = varNum

  varY2 = varY+5

  star:append(varX, varY)

  star2:append(varX+5, varY2)

  local simpleTransition = transition.to( star, {time = 600, x = star.x - 50} )

  local simpleTransition = transition.to( star2, {time = 600, x = star2.x - 50} )

  number = number + 1

end

timer.performWithDelay( 500, addNewLine , -1 )

[/lua]

Thanks for the answer.