Dec 082010

This tutorial explains how to wrap your iPhone applications screen.

Is that the right terminology? I have no idea. It has something to do with wrapping something. Now my mind is stuck on all the Christmas wrapping I need to do. Dammit.

Anyway, I don’t have long, it’s been a killer day and I have more to do yet, but this tutorial is just a basic little thing like I used on the hero star character in Happy Doodle Sushi Smile. (Yup, it’s in bold because it’s important! :P)

Copy the text below and place it into your file, immediately underneath the code you used to set up your hero/main “actor”. (I know we don’t call them actors in Corona, but I do.)

local function wrap (event)

if heroright.x < 0 then heroright.x = 310 end if heroright.x > 310 then
heroright.x = 0


Runtime:addEventListener("enterFrame", wrap)

Next up; We need to fix the hero’s name. Mine is “heroright” which is a terrible name but I was too lazy to change it and now have continued to use it in HDSS 1.5 which is currently awaiting release pending Apple’s approval.

So, either manually go through and change “heroright” to “myhero” or “hero” or “imsuperawesome” or whatever you have named it, or use Ctrl+f then simply type in the find box “heroright” and below in the replace with box type in your hero’s name. Either or.

Notes: This is set up for an app running in portrait mode and only wraps on X (left and right) – so if you want it all wrapped you’ll want to do the same for Y (up and down). Ask me if you need help, as per usual!

I hope this helps some of you – sorry it’s not quite the same super professional style I usually go for (eh hem :P) but I’m currently exhausted after being on my feet all day.

Enjoy, more to come!

Peach Pellen :)

Like this post? Subscribe to the monthly newsletter!


  10 Responses to “How To Wrap Your iPhone App’s Screen”

  1. hi, thanks. figured it out. it works now:) great tutorial

  2. The code is correct. Paste your whole file with plug and play code and I’ll try to take a look – but it works – on the X – you need to add in Y if you need it.


  3. hi, i have tried copying the code to my main.lua but, the only thing that happens is that my character stops moving and it doesnt get wrapped.

  4. the screen is still not being “wrapped”. nothing happens.

  5. hi, i tried copying this code and changing the name of my character to the “heroright” and placed the code below my character, but it still didnt work. please help.

  6. For anyone looking here in the future; use your screen’s dimensions. Of course you can’t use 310 is your screen’s height is 480. Try 470 or thereabouts, depending on the size of your actor.

    Tareq, I’m not sure exactly what you are saying – that he moves up faster than he moves down, or there is a delay when he moves up but not when he moves down?

    That would be something in your code. You need to look it over and test it, if that is indeed the case.

  7. I solved my problem, I have another question , that is ,

    for example there is delay when my actor go to down, and i want him go to up, he go up, but 2 second, or one second , how can i solve this delay , because when he get close to enemy and I want him go to up, very fast, he collide w enemy, because this delay ,

    I dont know if the (( friction , density )) related w this problem ?

  8. I have problem with that, because when my actor go above x = 310, it show in x = 0 but the problem in this case my actor can not move, except if I move it back (( I mean move it less than zero, it show from the x=310 and it is work,

    this is my accelerator function
    local function onAccelerate( event )

    frameUpdate = false

    player.x = centerX + (centerX * event.yGravity * -1)

    player.y = centerY + (centerY * event.xGravity * -1)


    and run time of this code

    then ur function,

    my screen not portrait , so that my accelerator function is changed,

    would u please insert the example with file, or write the all function

 Leave a Reply



You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Notify me of followup comments via e-mail. You can also subscribe without commenting.