Jun 192011
 

Corona for Newbies Part 4 introduces physics.

Finally, a new part in Techority’s Corona For Newbies mini series!

This covers all of the basics that you need to know about using physics in your iPhone applications; setting up, adding bodies, body types, properties, setting gravity and collision detection!

Collision detection is explained in a simple way that I believe will clear up a lot of people’s apparent confusion over how to implement it into their iPhone apps correctly.

Download Corona For Newbies Part 4

Enjoy!

And please, show appreciation if this helps you – even if you don’t want to donate Tweeting, Facebooking, etc. all helps me out!

Peach Pellen :)

PS – On a personal note, I’m sorry I haven’t been around as much lately. This is a private matter however I assure you that before long I’ll be back to giving Techority and the community the attention they deserve. (Plus I’m hoping to come up with some kind of community event we can put on; got suggestions? Let me know!)

 

Like this post? Subscribe to the monthly newsletter!

 

  79 Responses to “Corona For Newbies Part 4 – Physics”

  1. Hey G$,

    Going out shortly but, and I know this might sound obvious so sorry if you have – but have you set a radius for it? It sounds like you haven’t. Maybe.

    Let me know.

  2. Hmm, I can’t get this @#$%^ ball to play nice.

    No matter what I do, the ball slides instead of rolls on the ground. What’s funny is when it hits a platform from an angle, it will spin accordingly, but will either continue to spin, or act so freaking odd.

    I’ve tried friction 0 to 100, set scale from 10 to 120ish, doesn’t seem to matter. It’s almost like this particular physic’s piece is broke or something.

    I’m going to post on ansca with code and see what’s going down.

    g$

  3. Ok, I would like someone else to test this out on a device.

    ios 4.33

    I took the “chains” demo from corona, added Peach’s accelerometer control and commented out the Y tilt (that was causing issues in itself, the object would “absorb” or go through objects…..weird?)

    I renamed the super ball.png to just ball (cuz peach’s code was using ball and I was lazy).

    A couple things I noticed. I noticed on the simulator, things work as expected WITHOUT the tilt control.

    On the device, the ball comes down then bounces and sometimes keeps spinning (I could probably used fixed rotation to fix that, no biggie there) but then things get wierd

    1) Either the ball will act normal for a little while then all sudden just BOUNCE SUPER FAST OFF SCREEN

    2) Ball will get controlled by tilt, making me happy then I’ll tilt it towards the left ramp then it goes up the ramp and sometimes will get caught and just bounce wild or stop, or

    3) Big fluffy kittens fly across the screen and attack me….ok jk, just making sure you were still reading

    4) If I leave the device alone for a bit, the ball will just start doing stuff on it’s own, bouncing wildly, moving off screen etc etc etc

    I’m sure this is old news to you Peach, but it seems the simulator vs device are at times a DIFFERENT BEAST ENTIRELY?

    Ok so here is what I was thinking is going on, maybe right maybe wrong I don’t know.

    Collision detection – Maybe I need to set up collision detection of some sort, not sure how that would calm the ball down, I just don’t know enough about programming corona sdk to know :|

    Some other little tricks or features I am not aware of.

    My entire game revolves around tilt and a ball, and this behavior is just insane!

    Anyway, code is below. It’s from the CHAINS demo from Corona SDK, (I took out the chains as I wanted to strip things down to vanilla to troubleshoot), I renamed the super_ball.png to ball.png and plugged in the tilt controls (without the Y acceleration, or at least I think that’s what I did :)

    -G$ out.

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    display.setStatusBar( display.HiddenStatusBar )

    local physics = require("physics")
    physics.start()
    physics.setGravity(0,9.8)

    physics.setScale( 60 )



    -- The final "true" parameter overrides Corona's auto-scaling of large images
    local background = display.newImage( "grille_bkg.png", 0, 0, true )

    local ground = display.newImage( "ground.png", 0, 420, true )
    physics.addBody( ground, "static", { friction=0.5 } )

    local beam1 = display.newImage( "beam.png" )
    beam1.x = 20; beam1.y = 350; beam1.rotation = -40
    physics.addBody( beam1, "static", { friction=0.5 } )

    local beam2 = display.newImage( "beam.png" )
    beam2.x = 410; beam2.y = 340; beam2.rotation = 20
    physics.addBody( beam2, "static", { friction=0.5 } )

    local beam3 = display.newImage( "beam_long.png" )
    beam3.x = 280; beam3.y = 50
    physics.addBody( beam3, "static", { friction=0.5 } )


    local ball = display.newImage( "ball.png" )
        ball.x = 50
        ball.y = 50
        physics.addBody( ball, { density=2.0, friction=0.5, bounce=0.4, radius=24 } )


    -- Call the above function 12 times
    timer.performWithDelay( 1500, randomBall, 12 )




    local motionx = 0
    --local motiony = 0

    local function onAccelerate( event )
    motionx = 35 * event.xGravity
    --motiony = 35 * event.yGravity
    end
    Runtime:addEventListener ("accelerometer", onAccelerate)

    local function moveball (event)
    ball.x = ball.x + motionx
    --ball.y = ball.y - motiony
    end
    Runtime:addEventListener("enterFrame", moveball)
  4. Haha, hey G$ :P

    Stick with it, it always takes some work to get through little issues like that at first. (There’s threads on the forum about all of it.)

    I just got done showering and my toes are freezing >.<‘ I hate Winter. Summer too, for that matter. Stupid Australian weather!

  5. Crazy. Well the pressure is on now!

    I’m having all kinds of fun. Things that work in the simulator, just don’t work on the device. I got all kinds of weird issues

    Some highlights, when I use tilt to control a bouncing object sometimes the object will “absorb” into an object, or just go through it if it’s going fast enough. Or sometimes the object will just FLY AWAY SUPER SUPER FAST.

    I think *maybe* it has something to do with collision detection, I know there is something I can change that updates times per second at the cost of performance, but I’ll have to search more on that.

    Yea, I feel the pressure now. I am like OOOOOOOOOOOOOOOOOHHHHH CRAP ITS ON NOW!

    Worst case, if I can’t sort some things out I’ll ensure I got the “core” stuff working. I have a bunch of fancy pants features too, but I fear I will run out of time with all the things I want to do.

    g$

  6. Just woke up again XD (Late night.)

    To your question!

    That is correct. It is reserved, you do have to upload within 90 days, yes. I’m not sure if someone else can get it after 90 days or not, but no, you can’t.

    Peach :)

    PS – When you upload change the release date to like, a few days after you submit it. You want it listed on the store as soon as it’s approved. If you have the date set at Oct 01 and it is approved on Oct 02, it will go up immediately.

  7. toast FTW.

    Yea people say I am very excitable about everything. Doesn’t matter how tired I am, if there are people up I will ALWAYS be the last person to go to sleep. I’m pretty hyper 24×7, even though I’ll be 36 this year..haha.

    Yea, I have pushed 11 variations of my game to my itouch. I was amazed at the performance. I am using tiled/ lime + svg level builder. But that Jay guy from gamedevnation wrote a snippet of code that spits out code for wherever you drag an object in the simulator. I found that interesting for quick sketches.

    Ok so I have a question. I submitted my app name, the first one I picked was taken, the second one I picked was not *yay*. Then it asked me to rate it, and give a release date etc. I picked October 1st, I dunno just felt *right* to me lol. In the status it says “ready for upload” does that mean I my app name is reserved? Also, somewhere I was reading was if I don’t upload a binary within 90 days (I think) i lose the name and I won’t have a chance to get it back, but someone else could.

    mmk that about does it. So glad I can just focus on developing and SEEING my game on my device instead of messing around with the jack wagons at Apple haha. ;)

  8. I literally just dragged myself out of bed so I will keep this short as my computer screen is blinding me.

    I laughed at your posts, but felt most relieved for you that you figured it out. It gets easier and easier every time :)

    I’m going to go eat something while still laughing at the above comments; glad you got it in the end.

    *blindly stumbles off for toast*

  9. ….finally. I was able to push out my app to my itouch. feels like an eternity trying to figure out mac, xcode, lua, corona, apple store, bla bla bla.

    Now I am going to eat a burrito and a margarita!

    Thanks, your instructions helped out a bunch (especially the dragging to the itunes, that part I was like EH?).

  10. WOW IM SOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO RETARDED.

    Lol, I am so stupid with macs right now you will find this so funny.

    See in windows PC land, I would read the above instructions as within the application, but on a MAC they put that window at the top that contains the options for the application….

    LOL. So I clicked on it and now I’m good. It’s the same way when you open stuff and it goes to the doc, im like “WHERE THE HELL DID IT GO OH YA ITS DOWN THERE DUHHH!”

    Yea, im lame hahah. Well that was entertaining. ;)

  11. I don’t have a “certificate assistant” as in It’s not there. I went to a Mac store and looked on one of those machines, that thing isn’t there either? Wtf lol.

    I must be blind or something.

    I go to my applications folder – check

    I open up utilities – double check

    I open up keychain access – triple check

    “Choose Keychain Access > Certificate Assistant > Request a Certificate from a Certificate Authority.”

    ^^ that right there is where I can’t get to – I am looking to choose “keychain access” while I am inside the “keychain access” utility to select “certificate assistant”

    I fail so hard lol. I went around online seeing other people who have this issue, they say click on the top where it says “keychain access” – they must have magic macs or something cuz I ain’t got nuttin.

    I’ll search around some more :) ….at least the App names I want are not taken yet (I checked on the applications naming selection and release date thing on itunes connect :) :) )

  12. Because this stuff isn’t exclusive to Corona (it’s done the same way for all devs, even those using Obj-C and the official SDK) there isn’t a huge demand for documentation – namely because there’s SO much of it out there already. (The only difference is when you open Corona and hit “Build”, that’s it.)

    As to emailing me, I have two – the one you should use is my name, all little letters, at gmail.

    …. Now, you don’t have keychain access, is that what you’re saying? :S Or you do have it but can’t work out making a certificate>

    Sorry for the late reply, been sleeping ^-^;

    Later G Money :P

  13. Ahh. This thing driving me a nutsa.

    Choose “keychain access >certificate assistant >request a certificate from a certificate authority

    Part of the instructions on the itunes connect site…..so I go to my apps folder, launch utilities and then go to keychain access…FINE. the Keychain access >certificate assistant I don’t see I looked everywhere!

    I’ll search around, I know you are busy. I’m confused on the APP ID, and all this crap it’s like they don’t tell you what’s good practice or what you are stuck with or what.

    Okie dokie, i’m sure i’ll spend another few hours banging my head on it! hahhahahah? ;)

  14. Sweet. I’ll give that a shot, I upgraded to 10.6.8 and safari was FREAKING out and freezing all the time. I thought I was crazy, but people who own “real macs” were having the same issue.

    I had to uninstall flash and then go to finder, get info on safari and run in 32 bit mode, reboot then go back in and uncheck and voila works fine now….weird.

    Thanks for the reply, I had no idea about any of this. I think Corona NEEDS to have this on there, as they have a small guide, but doesn’t mention JACK BEEP about all the stuff you mentioned.

    Ok, off to go give this a shot. Stupid question, I see you have twitter and facebook, but looked for email address and can’t find it? I guess maybe my questions and your answers will help people, but emailing you directly and then posting the final results I guess would be handy.

    Nick “g money” lol.

  15. Haha, I’d do a forum but it seems like overkill as I spend so much time on the Corona forums and, you know, I can be contacted via email, Twitter and Facebook as well :P

    As to how to do that; I hate that question XD (Get asked it a lot, never save my answer.)

    1. Make sure you have created your certificates.
    2. Create App ID in the provisioning portal
    3. Create a provisioning profile (AFTER adding your device.) and tick your device. It’s AdHoc not AppStore.
    4. Download the profile. (It will say pending, refresh once, you can download it then.)
    5. Double click it to add it to Xcode. If you can’t see it there, double click it again. It wont get double-added or anything.
    6. Open your app in Corona
    7. Hit CMD+B to build it.
    8. Choose the profile you just added. (If Corona was running in the background quit and reopen or it wont appear.)
    9. Plug in your iPod. Drag the UNZIPPED file from your desktop into the iTunes icon in the dock.
    10. Sync.

    The icon in iTunes will be a developer one. Ignore it, don’t panic, it’s normal.

    Now, I’ve been awake for 13 hours and been working for 12 of those, so it’s time for me to finish emailing people (a mountain still awaits me) and then chill.

    So, I hope that helps – later, G Money. ;)

  16. Ya, I DL’d Xcode!….now i’m confused.

    I’ve been scouring ansca’s site for a hold my hand walk through of the following
    (I have a cor sdk ios license, and developer license from apple, so I think that’s what I need)

    I’ve built a game
    I want to push the game to the ipod touch, but I am not sure what I need to do it?
    I’ve read about using xcode and tra la la, but I’m confused?

    Could you give me the quick and dirty (ooh la la…..lol) on how you push a game to your device? I Figured since you have done this so many times, a quick

    “Ok G money check it out right here homeboy, you go here and there click this, dont do that cuz of this, and then bam in yo face son!”

    lol, something like that?

    Btw, I think you seriously need a forum or something as I have to use a unrelated topic to post something :)

    weee!
    -Ng

  17. Hey Nick :)

    I know what you mean about seeing it in your own hands; the DL will go faster if you plug in an Ethernet cable rather than rely on WiFi, if you have got that option? :)

    The weather here, being Winter, is around 35 to 60 depending on the time of day. (I had to look up the conversion. We use Celsius, of course.) I know many places get much colder but I’m not acclimatized to it at all.

    As to whiskey, I’m too broke to buy any right now so I settled for cheap wine – but I am a fan of whiskey. ;)

  18. MMmmmm spam..

    That’s right it’s winter down under? It’s 96 degrees out here in California.

    I didn’t realized I needed apple sdk, jeez its 5 gigs I’ll have to DL that tonight so I can push out my app to test…..I can’t wait to SEE IN MY OWN HANDS my creation. That is seriously LEGIT.

    Yea!

    PS drink some whiskey, or that will do the trick!

  19. Hey, sorry, busy day!

    Great news on the licenses – they will pay for themselves after a short time if you remain persistent and committed :)

    Must run, many, many emails to get to – then I have to go make sure no one is spamming the forum XD

    :)

    PS – My house is freezing.

  20. Well, i’m legit now. I just plunked down $100 and $200 on a Apple dev license and iOS cor sdk license.

    Holy cow, this is exciting!

  21. Good times! Glad to hear things are going well. In regards to jumping, it’s something I want to make happen. Instead of having the player jump when they want, I want to take that control away and give it more of a timing type of things where you get X amount of bounces and something bad happens if you go over that limit.

    When I get these things hammered out (along with director), then I will treat myself to a cor sdk pro license and an apple dev license…w00t.

    -Nick

  22. I know how you feel; me, I used to really hate Macs – then I got given an old iBook G4 and really got into it. Since then I have only ever owned Macs. (Not that I wouldn’t mind a PC again as an option one day, but if it’s a choice between the two it’s definitely a Mac.)

    I always install Windows for the option of dual-booting, but never actually use it. Lol.

    Glad director is working even if it isn’t intuitive for you yet; it will be. Once I got used to it I used it for everything; it’s in literally every single app I’ve ever published or made for a client with Corona. (40+).

    Stick with it and you’ll get there; I have always hated jumping myself – maybe that’s why I rarely make platformers, haha. One day I will – probably AFTER learning all about CoronaUI, though. (I need to do that. Badly.)

    Template sale has been going pretty well; finally got a proper redirect on the old site working. (iWeb made it all messy.)

    :)

  23. I am looking forward to the MAC, the more I use it the more I love it. I’ve always been against mac until Corona SDK came into my life.

    I don’t know what it is about the director, and scene thing. I just tried it out doesn’t seem hard :) BUT for whatever reason, even though I got stuff working I feel weird and out of place about it.

    I did get my game working with director to load one level.

    >>>>>>>I STILL can’t figure out the jumping loop though<<<<<<<<

    So far I have done the following:

    Built level 1 (ya, ONE level) – level building for me is CAKE. I can whip it out in about 15 minutes.

    Wrote my soundtrack (I play drums, bass, guitar and keyboard, and one of my favorite bands is NIN, Johnny cash, Lynyrd Skynyrd and *some* cannibal corpse along with Lady Gaga and Depech Mode- that's what I call a mix)

    Built a semi complete asset set (traps, platforms, objects, etc)

    What I am working on now:

    GOAL – Basically get to the goal and have the game give a time for completion

    *I am thinking 3 times that are 1, 2 and 3 stars for various times.

    Timer – a timer that runs until the goal is reached

    Ehh, that's about it….oh there will be some open feint, facebook, rate app stuff but I'm saving that for last.

    When I write it out like that, I don't feel that bad now? I've actually only spent about 20 hours or so on this, and more than 75% of that time was just learning how to do stuff, the coding felt like a minute or two for certain things…..hmmmmmmmmmm

    ahh long post, but it was on my mind. YEA!

  24. It is easy, trust me – just look at the tutorial on here :)

    Me, I never worked as anything so fancy; I’ve been lots of different things, though.

    You’ll recoup the costs, buy a Mac and sit in a closet using Corona WHILE singing “I GOT A MAC!”

    Peach ;)

  25. Director is easy? I’ll take a look lol. I work as an application support analyst and a “Principal Call Center Architect” and I deal with very very complex things. Yet, this programming thing? Got me confused.

    Thankfully, I was able to build 60% of my game so far with “copy and paste” :) I know that’s kinda sad, but I UNDERSTAND what those things do and I was able to change them around. It’s when I want to cook up something new (like this jumping loop) I don’t know/brain freaks out trying to do it.

    Yea, I am eyeballing the mac mini (in the states we get them for about 600, I’m looking around for a used one now). Since I am always traveling around, I use my Hackbook Pro (lol) to work on things.

    Nice on the new icon/logo.

    I figure this much, when I release an app (cuz its WHEN not IF) and I recoup what I put into it so far (licenses for apple, tools like svg level builder, LIME, texture packer, bla bla bla) meaning I break even then I will

    BUY A @#%%%@ MAC BOOK PRO AND BE SO HAPPY! I will buy the biggest one with the most bells and whistles and then I will hold it in the air and dance around the streets singing “I GOT A MAC I GOT A MAC LA LA LA”

    ….or I will just lock myself in a closet and develop on Corona sdk :)

  26. Director is EASY – I have a tutorial for it. Search for “scenes/screens” – that’s director :) Has a sample project and all.

    If you want a cheap “real” Mac, look into a Mac Mini – good condition, 2nd hand one is fairly cheap – or new, even. Assuming you have monitor, mouse and keyboard.

    I know what you mean about money but me, I love my Macs – wouldn’t feel professional without them ;)

    Side note; working on a new icon/logo for Techority. It’s a pixel art iPhone ^-^; I love pixel art.

  27. New apple license, ok. I figured lol, thought I was sneaky sneaky.

    I’ll keep plucking away on this jumping thing. I have a task list of things needed for my game, and checking them off. Now I neeed to figure out how to use director, or something to go from screen to screen, and memory management of objects etc….another thing I have NO idea how to do lol.

    If you already have a MAC then you are cool, but since I have 2 laptops and one doesn’t get used it’s a macbook pro that cost me next to nothing (since I get 2 laps at work). I would like a real macbook pro, but that’s a lot of cash that I need to get – my next purchase (besides cor sdk license, apple dev license) is an ipad2. All that $ that I would spend on a real mac, buys me the ipad, itouch, cor sdk license, apple license and I still have $ left over w00t.

    Take care – Nick

  28. You will need an Apple License as well, I’m afraid.

    I did read your whole post, I’m just too busy in the middle of some work to response further; but nice on the Hackintosh – me, I need that new Apple smell ;)

    Peach

  29. Ya I don’t know wtf I can do with it in regards to this jumping challenge.

    I know doodle jump does it, now I am like HOW HOW HOW.

    I use a hackintosh (Snow leopard installed on a dell e6500) for my development now. I want a mac book pro, but I don’t want to spend 2000 on one, so I use one that I have for *free* at work, just have to do a little musical hard drive swap a roo!

    All it cost me was a little time + 29 bucks for the snow leopard DVD

    Now, I am looking at the license and I have a question. To simply test on my itouch, do I just need a corona sdk license, or do I need the apple dev $100 license in addition?

    *on the template idea, ya it would be nice, soon as I figure it out I’ll post on here as well. I know I am close!

  30. There’s a chance you could do it without applying linearImpulse – maybe a transition.to instead?

    I should look into this myself sometime, could make a neat template if I actually figured it out ;)

    I have an iPhone4, so basically the iPod with text/call – and yeah, they’re great :D

  31. “Glad to hear about your jump situation – thanks for sharing it What is the friction/bounce/density set to on the ground, or platforms, or whatnot?”

    I am glad you asked.

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    --For the ball
    local ball = display.newImage( "ball.png" )
    ball.x = 150; ball.y = 220

    --This line for the "ball" allows a perfect bounce which stays very even, and sometimes alternates

    --between a tiny bit higher or lower (seems to go back and forth between the 2)
    physics.addBody( ball, { density=1.0, friction=0.5, bounce=0.97} )

    local ground = display.newImage( "ground.png" )
    ground.x = display.contentWidth / 2
    ground.y = 445
    --OK now we have to define the ground's physics. We can say it's "static" and assign some friction and bounce to it
    --Friction would be the resistance objects have against it, and bounce is, well how bouncy it is :)
    physics.addBody( ground, "static", { friction=0.5, bounce=0 } )

    Ok so the takeaway from this is if you load up an image (or a rectangle for the ground, your choice) and you load up a ball, or box, or crate (Corona’s sample code for that crate physics demo works wonderful) you can see this in action for yourself.

    Some things I have noticed:
    When you fire up the simulator, if you take a sticky note and put it on the highest part of the bounce and stick the note there, you will see the object (crate, ball, whatever it is) will bounce to that line on the bottom of the sticky note….and it will *SLIGHTLY* alternate at random between a pixel or 3 higher or LOWER but is from what I can tell CONSTANT.

    Some things I am working on now:

    My goal was to control a bouncing object, however I have noticed that the height of the bounce changes when the object goes onto another object that is higher than the ground it was on, thus the bounce becomes not as high.

    let me do some asci art or something The O is the ball or whatever you want.

    —- < A) original height of the bouncing object
    _____< B) this underline is the NEW height of the bounce on top of the new platform
    O _____< C) this underline is the next platform, or piece of ground or whatever
    ________

    So now I am working on a jumping loop (again) which I have NO IDEA on how to do something like that. I know applylinearimpulse is needed (duh) and then some kind of collision detection for isGround or something (so I can't double jump) but now I don't know the syntax…..arrgh so painful this process is!

    Anyway, ya there it is.

    Back to work for me :)

    I have NOT tested:
    Haven't tested on a device yet (im not licensed yet, but I did buy an ipod touch 4th gen :) omg it's so awesome)

  32. Hey, not been up long so still a bit dopey.

    Glad to hear about your jump situation – thanks for sharing it :) What is the friction/bounce/density set to on the ground, or platforms, or whatnot?

    Density yes, is like mass, as far as I understand it.

    In any case, glad you’ve got it all working as intended :D

  33. OK I GOT IT!

    I didn’t do the jump loop (I couldnt’ figure it out)

    But with the right combination of density and frection, and bounce you get a consistent bounce.

    What I did was tape a sticky note to my screen so I could measure the height, then I let it run for over 15 minutes – it still going to the same height.

    1
    physics.addBody(player, { density = 1.0, friction = 0.3, bounce = .95 })

    Now here is the thing if you change the density, then it WON’T work…….unless you mess with bounce some more.

    I was sitting here thinking about REAL LIFE PHYSICS and realized, hey this is MY GAME I DO WHAT I WANT YOU HEAR?

    lol. So basically, the density is what does it. If you set it to 5 or 10 or whatever, then the bounce setting gets jacked.

    Some things I have noticed with Density. If you put a “applyLinearImpulse” (aka JUMP) on an object the the higher the density, the lower the jump will be (from what I have saw so far anyway). If you lower the density, the higher it will jump. I guess density is like mass or something, I have no idea.

    Felt like I burned up a lot of time when the answer was right there. It is possible, and as I am writing this it’s been about 23 minutes and the object is bouncing exactly the way it was, not even moving a pixel. I figure this is good enough, I can’t imagine a player lasting that long in my game (if they last 8 seconds, that would be amazing lol).

    Anyway, ya im happy now. haha.

  34. Heya,

    A short one as it’s 5 AM here now – I’d consider using collision detection. When the player collides with the ground/platform/etc then call it.

    Make sense?

    Peach :)

  35. Hmm, just sifted through a lot of crap. I can’t get this jump thing to work ( I cant explore the tilt option yet, as I don’t have a corona sdk license yet and I plan on this once I get to a beta stage).

    1
    player:applyLinearImpulse(0, -7, player.x, player.y)

    Ok I KNOW this allows to jump
    (*ya, there are some other functions and crap with it for touch events, my game doesn’t use touch at all only tilt.

    How would I loop the above? I just want to execute it over and over again. Yea I know there is also collision detection and making sure jump can’t repeat itself unless it touches the ground, etc etc.

    Just keeping it simple, I’ll start with the above code snippet :)

  36. Hey again,

    I think the jumping loop probably makes more sense, to be honest. I would certainly try that first.

    And that’s a good saying; I might have to steal it ;)

    As to not sharing too much info, I get it – I do it myself – you look back at some of my old forum posts and you’ll see that I too disguised what exactly I was working on, hehe.

  37. Continued from “news” section

    I was discussing people working together to share code. I wasn’t saying that someone should reveal everything, but rather focus on specific pieces and thinking about things in a different way.

    For example – I am having a HELL of a time with Bounce and getting it to stay the same. My original intent was to get an object to bounce up and down at the same height every time. I realized that due to limitations in Box2d (the underlying engine in corona for physics) that it rounds numbers and therefore over time it will get lower and lower or higher and higher…..

    I have a new saying “Control the things you can control” – Obviously I have no control over limitations of Box2d so I have to get creative.

    -I was thinking that maybe I can have an object “jump” and put it on a loop so it repeats itself, and have the ability to control the object with TILT controls.

    Think : Doodle jump.

    See what I did there? I shared a PIECE of my game, but you can’t possibly figure out what it is. Yea, I say “doodle jump” but the element of control that’s being used there is something I want to re purpose for it.

    Anyway, thats my thoughts on it.

    @ Peach, I haven’t gone that route yet on linearVelocity, I think I want to explore the jumping loop idea – if you have an idea on this let me know :) I’m all ears/eyes!

  38. Hey Nick, sorry, been flat out.

    Just woke up but maybe you could try applying linearVelocity (upwards) when the ball hits the ground but having bounce at 0? Would that work?

    Again, half asleep so I could be off ;) But worth a go.

    Peach

  39. I just thought of something in regards to my bouncing object issue. Instead of having something bounce at the same height, couldn’t I just assign some sort of loop to make the object continue to jump (think doodle jump, or any of those jumping games)

    Hmmmm. Now I just have to find out how to do that……bah the quest continues!

  40. Peach,
    I have question. I have ball. I have ground. I want ball to bounce on ground. I want ball to bounce on ground at the same height every time, no exceptions.

    How can ball bounce like this?

    It will help if you imagine russian accent to the above request, lol I wanted to keep it as simple as possible. I’ll post on Ansca as well. I am having issues with bounce, I want things to stay even I want a ball to bounce say 2 feet up and constantly bounce and not stop, no more no less :)

    Thanks again.

    -Nick

  41. Heh, I know how that goes – although you sound more organized than me ;)

    I have a lot of ideas too that I can’t yet bring to life as I lack the time to learn new things – I mean, I know a lot, but there are some things I need to know before throwing myself into anything new.

    One day!

    Back to work with me :)

    Peach

  42. The problem I have now is I have over 29 ideas for games, that utilize completely different gameplay mechanics.

    I am basically going through every tutorial and I see a piece of something that I need, like something gets spawned somewhere then collides with something and becomes more powerful (powerups).

    Then I sit there and have this stitched together code that reminds me of some crazy blanket made of little pieces of blanket to make one large blanket.

    Then of course I plug that stuff in and stuff of course doesn’t work and I have to hunt down references to it all and try to get things working – while trying to learn and understand it in the first place!

    I use Microsoft One Note due to the air tight organization it offers me, I keep my code samples in there along with my stick figure sketches (you can draw in there too) and what’s even cooler is I can EMBED files in there. So all of your tutorials, I just drag and drop to a page name it whatever and then I have it sync with my Android.

    I bought PRogramming in Lua 2nd edition, Lua Programming Gems, Lua 5.1 reference. I plan on going Pro on Corona SDK license soon as I get something tangible to publish, then of course I have to buy the dev license from Apple…..arrrgh too much to learn not enough time!

  43. Hey,

    I actually have a side scroller with a power up, haha, it just doesn’t have the y thing set – but as objects spawn off screen and move on they push each other so they aren’t on top of each other by the time they’re seen. (They’re physics objects, obviously.)

    Maybe I should look at a video series; I made one once as a paid gig, couldn’t hurt to try again for my own site :)

    Peach

  44. Well, I could use some help with object spawning. Or maybe taking a basic side scrolling game that includes a power up, controls and scoring system and breaking it down.

    Or, you could use your template for this and if someone buys your video tutorial, then you could discount the template?

    Right now I am working on spawning objects from one side of the screen, and having them go left to right, but I don’t want them to spawn on top of one another so I am trying to figure out -x- and -y -auto- -detection -logic- don’t- spawn -here -if- there -is -something -there-and-also-go-in-an-arc.

  45. Sorry hadn’t seen your second comment when I made mine – and no worries on how often you comment; you’re on auto approval so it’s not hassle for me :)

    I’m glad you liked the style; I felt it flowed well.

    I’m hoping to be more active with Techority soon after this bit of a lull – so maybe a part 5 will be coming soon – I just don’t know what it will focus on yet ;)

    Peach

  46. I am planning a more robust Techority by August if I can manage it and perhaps this could be a part of it :)

    I do like the idea and normal folks wouldn’t miss out either – it’s just a matter of managing my time. Between the Ansca stuff, Techority, my own app work and of course my templates I do have trouble fitting it all in.

    Ah, one day I’ll do it all ^-^;

    Peach :)

  47. Ahh sorry another post. I like the style of these tutorials. “New stuff below here” I think that’s great. I went through the tutorials in a few minutes and I was able from memory to recreate.

    I understand it much better than before.

    I am ready for part 5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21……lol.

  48. Btw, in addition to doing these tutorials, maybe you should consider a “premium content” area.

    Basically, you offer your commented code for free, and then you either charge a small monthly fee of something like $5 or w/e and a person can view content. You could take the same thing you provide to us for free and then take it many steps deeper to explain the logic behind the code. Basically hand holding to the extreme!!!

    Trust me, if you did this people would do it. I SCOUR the internet every day looking for something that will help me – all I find is a bunch of wordy mumbo jumbo that I don’t understand WTF they are talking about.

    I know you mentioned something like this in another section, but I don’t think you thought of this route?
    I am so on board with Corona, that I am filing a DBA (doing business as) for my game development company and I would gladly pay for ongoing training like this.

    I think you should do it sooner than later, the worst that can happen is it doesn’t work? Do something like make an area for subscribers and go back to part 1 make in depth videos for them and charge a small fee, either per tutorial pack or a monthly fee.

    Just go for it!

  49. I just saw that!

    Thanks so much :) I recall you saying you tried to donate; and here you are succeeding despite Paypal’s somewhat tricky ways ;)

    Really appreciate it :)

    Peach

  50. I just donated $10 to you. Worth every penny.

    I said somewhere else I tried to donate, but lame paypal was rejecting my card……now all sudden it works again. Go figure? :)

    -Nick

 Leave a Reply

(required)

(required)

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.