move object

hello my friends, I need to move a rectangle that occupies the width of the screen, raising it from one side or another and that goes up as I touch the screen, they know the way I can get it

not clear on what you want.  Can you draw a picture and attach or rephrase that.

You lost me on “raising it from one side to another”.

Do you want to do the following?

  • draw a rectangle at the bottom of the screen that is as wide as the screen and some number of pixels tall.

  • move that rectangle from the bottom of the screen to the top when the user touches the screen and keeps their finger on the screen.

  • stop moving the rectangle when the player stops touching the screen.

    local fullw = display.actualContentWidth local fullh = display.actualContentHeight local left = display.screenOriginX local top = display.screenOriginY local left = display.screenOriginX local right = left + fullw local bottom = top + fullh local cx,cy = display.contentCenterX, display.contentCenterY local moving = false local rate = 100 – pixels per second local lastMove = system.getTimer() local block = display.newRect( cx, bottom - 20, fullw, 40 ) function block.enterFrame( self ) local curT = system.getTimer() if( moving ) then local dt = curT - lastMove local dy = rate * dt/1000 self.y = self.y - dy end if( self.y < top + 20 ) then self.y = top + 20 end lastMove = curT end Runtime:addEventListener( “enterFrame”, block ) local function touch( event ) if(event.phase == “began” ) then moving = true elseif(event.phase == “ended” ) then moving = false end return false end Runtime:addEventListener( “touch”, touch )

May Have Typos

not clear on what you want.  Can you draw a picture and attach or rephrase that.

You lost me on “raising it from one side to another”.

Do you want to do the following?

  • draw a rectangle at the bottom of the screen that is as wide as the screen and some number of pixels tall.

  • move that rectangle from the bottom of the screen to the top when the user touches the screen and keeps their finger on the screen.

  • stop moving the rectangle when the player stops touching the screen.

    local fullw = display.actualContentWidth local fullh = display.actualContentHeight local left = display.screenOriginX local top = display.screenOriginY local left = display.screenOriginX local right = left + fullw local bottom = top + fullh local cx,cy = display.contentCenterX, display.contentCenterY local moving = false local rate = 100 – pixels per second local lastMove = system.getTimer() local block = display.newRect( cx, bottom - 20, fullw, 40 ) function block.enterFrame( self ) local curT = system.getTimer() if( moving ) then local dt = curT - lastMove local dy = rate * dt/1000 self.y = self.y - dy end if( self.y < top + 20 ) then self.y = top + 20 end lastMove = curT end Runtime:addEventListener( “enterFrame”, block ) local function touch( event ) if(event.phase == “began” ) then moving = true elseif(event.phase == “ended” ) then moving = false end return false end Runtime:addEventListener( “touch”, touch )

May Have Typos