ex-GS users switching to CORONA

@jstrahan

Examples are always good, thats how I usually learn a new platform. Ive stuck up a joystick with examples in the sample code area for that reason. And im always happy to help and having released a full game which uses a lot the the functionality of Corona I can usually point you in the right direction.

The getting it bit, didnt mean coding as such, more game design and how to go about it. Discovering the power of groups and tables, understanding a little bit about opengl (like texture memory) and basic game functions / mathematical functions that will make programming your game much easier.

Lua, one day it just sort of clicks. To the point that now when im programming in php, javascript or whatever little bits of lua creep in (which is annoying). If you dont come from a programming background then it will be difficult to start with but not impossible, especially how lua is written and the inbuilt functionality of Corona.

@peachpellen

I totally get what you are saying ( and eating ) and it be could thinking in GS could probably help in designing the game as you would need to construct much of the same functionality. The difference in thinking here is starting with nothing and building up to something rather than starting with a dev environment (GS) and using it to construct the game.

So yeah you learned about functions and now you have that knowledge forever and you could pick up jquery and start programming webpages in a similar way as functions are pretty standard across most languages.

What is necessary when moving to a new environment is to set yourself a bunch of tasks that will, 1. remain as a reference for yourself and 2. act as a learning tool. This is the easy bit, plan what you need to know, File I/O, sprites, physics etc… and you make 1 sample app for each. This helps you learn the language, the theory behind it and also once you complete each one its another bit of knowledge you have acquired (with a lua file for reference).

So yeah before starting a game and struggling every so often, discovering a solution, maybe having to alter the code to accommodate and repeating the process many times it is better to build yourself a knowledge base first and then build from there.

In the long run starting from simple concepts and building upto something complicated is much better than just trying to build something complicated.

I dont even do this when I know a language, everything is prototyped as separate modules, debugged, the pitfalls learned and the prototype refined. [import]uid: 5354 topic_id: 2645 reply_id: 9681[/import]

I’ve gone thru the samples and all clicks (just need to get use to remembering which ‘method/property’ to use).
I feel capable of recreating one of my GS games (now with openfeint :wink: based on those demos; however, I really would love to see samples about Platformer games, constrains and controlling ‘actors’ (sorry for the GS reference :wink:

RD [import]uid: 7856 topic_id: 2645 reply_id: 9684[/import]

I take it an Actor is an in game object in GS and you in someway want to replicate that functionality in Corona, its been a while but I remember it being a lot like flash where I could select the object, set certain parameters and apply certain actions.

This is all well and good in GS as its how it works. Much like with Flash though once you need to do anything complicated you need to jump into actionscript.

In Corona, as you know, there are not really actors. We have display objects and thats about it. Ive seen some users trying to replicate the move to functions on GS with Corona transitions and thats what I see as part of the stumbling block some people are having.

They are looking into Corona for GS functionality where none will exist. The type of SDK Corona is, you are expected to develop your own specifically around the requirements of your game.

There are a few api’s like physics & collisions that will help you ( or you can just calculate your own collisions programatically ) but most other things in Corona are there to help you build complicated bespoke things from simple concepts rather than providing you with a complicated thing with a few parameters you can alter.

So to do a platform game in Corona you would need to do the following.

  1. Learn good platform game concepts
  2. Learn how to best implement those concepts in Corona
  3. Build you game around those principles
  4. Profit

Part of the fun is also designing how the game will work. This on its own will effect gameplay on a level that changing a few flags for an actor couldn’t.

But for a platform game, using Corona, you could do the following.

  1. Build a wall constructor class.
    You would need to probably define a grid for one which each section would ‘slot’ into. Each brick you generate would need a collision boundary adding, the graphic to use and its position.

so if I wrote a lua module called wallBuilder then I would populate it with a few functions, one that loads the sprite sheet and generates the required sprites to be used in the wall.

I would then build a function to place a new brick in the World display group.

For instance say wallBuilder.newBrick ( 0 , 0 , ‘wall’ ) would generate a brick, using the wall texture and place it at 0,0. wallBuilder.newBrick ( 1 , 0 , ‘grass’ ) would do the same but place a grass block 1 unit along from the wall sprite. This way I can generate tons of levels by just loading a table of what goes where in the level.

You would then have a platform game, with no characters, but the platforms are there. From that I would then need to think what happens if an enemy walks to the edge of a platform, would it fall, no. So what to do, I would then go back to wallBuilder.newBrick and extend it so if a brick ends and there isnt one next to it it would add a collision sensor so I could tell an enemy to turn around.

Once that had been prototyped I would probably set it up so every brick had the 2 collisions listeners (left of and right of) to stop a enemy from falling off but the code would then look when placing a brick to see if it did touch another and it would remove the listener to form a longer platform.

From that I could then construct an enemy class, a few simple listeners to control movement, interactions with the character etc…

There will never be a enemy class in Corona though so writing your own is important and as I mentioned will effect the dynamics of your gameplay more than you might know. Would the enemy just move left and right, simple change in its .x value with a rules for turning around when it hits a wall.

Alternatively though, maybe you want the enemy to have sight, that is if the enemy is not facing the character or is out of its visual field it wont attack and instead preforms some other task / animation. This is again easy and can be done an a number of ways, measure the distance and angle between the player and the enemy ( cos / sin etc…), setup a collision sensor that is on one side of the enemy with a distance that of its field of view. Use the platform as the sensor and have the platform tell any enemies on it to attack when you touch the platform.

So with the above method you would first look at coding a class to build a level, a class to control enemies, a joystick type input and the character. You would then need to move the world, keep score etc…

Each of these would be bespoke to your game, making your game unique for one. I can tell you how to save a score but I cant tell you how to save your score, that you would need to work out. [import]uid: 5354 topic_id: 2645 reply_id: 9693[/import]

@MP
Wow, you sure know your stuff :wink:

I haver seen the joystick demo, but would like to see a sample about ‘objects’, manipulating other object movement.
Example: when left button press, move object left; if button left and button gun press, shoot left.

Once I have those two samples, along with the current ones on the demo, I think I can take it from there (for basic stuff) and work my way up.

Thanks,
RD [import]uid: 7856 topic_id: 2645 reply_id: 9700[/import]

Start with the Hello World tutorial is my advice, then when you’ve done that try the 8 minute game video - that’s how I started :slight_smile: [import]uid: 10144 topic_id: 2645 reply_id: 9701[/import]

@peach
Me to but just looked at hello world
I can’t stand hello world programs although I understand why they do it
[import]uid: 7911 topic_id: 2645 reply_id: 9702[/import]

@rdcube

I will knock something together quickly ( the code wont be full working but will give you an idea or two )

@peach

The problem with Corona is that that hello world is too easy, its quicker to setup a 2D physics environment is Corona than it is to do a hello world in ObjC and even Cocus 2D. [import]uid: 5354 topic_id: 2645 reply_id: 9731[/import]

@peach,
Yeah, ‘hello world’ is a basic in programming :wink:
And As I said before, I’ve gone through the demos and piece meal pieces together, so I feel I’m getting it.
I know how to collide and have things appear from top of screen.

I’m trying to take the ‘crack an egg’ demo ad expand (it covers ‘spawning’, collision and ‘follow object with camera’).

@mp,
The egg one is probably a nice one to ‘hack’, have a button that once the ball is dropped (let’s stick to only one ball) make it move (left/right) and a button to make it jump.

Dunno, just a thought. [import]uid: 7856 topic_id: 2645 reply_id: 9745[/import]

@rdcube

Im having a discussion here about moving an object, ive just posted a way of moving an object around with physics. The normal way is also discussed but I can elaborate if you need.

http://developer.anscamobile.com/forum/2010/10/30/moving-object

What you need to do is two fold. First try it with a single button rather than the joystick

This is added to a button will power a function you can use to move something. Setup an image and call it button

local button = display.newImage( "button.png")  

you then need to setup a function moveTarget() which does something, like increase the x value by 1px every frame

function moveTarget( )  
 YOUROBJECT.x = YOUROBJECT.x + 1  
end  

then lets monitor the button for a touch, in this case we want a simple on / off type of touch so im starting a listener for the moveTarget function when the button is pressed and removing it when the touch ends

local function accelerator( event )  
 local this = event.target  
 local phase = event.phase  
 if "began" == phase then  
 -- Start Focus  
 display.getCurrentStage():setFocus( this , event.id )  
 this.isFocus = true  
 Runtime:addEventListener( "enterFrame", moveTarget)  
 elseif this.isFocus then  
 if "ended" == phase or "cancelled" == phase then  
 -- End Focus  
 display.getCurrentStage():setFocus( this , nil )  
 this.isFocus = false  
 Runtime:removeEventListener( "enterFrame", moveTarget)  
 end  
 end  
end  
button:addEventListener( "touch", accelerator )  

thats as simple as it gets.

To do a second button to fire a gun which is conditional on the joystick being moved as well you could set a flag if the fire button is pressed.

I dont know, something like YOUROBJECT.isShooting = true

then in the moveTarget function you can check the flag to see if its safe to move

function moveTarget( )  
if YOUROBJECT.isShooting ~= true then  
 YOUROBJECT.x = YOUROBJECT.x + 1  
else  
...  
end  
end  

remember when setting up YOUROBJECT, set YOUROBJECT.isShooting = false so the value exists to be checked against [import]uid: 5354 topic_id: 2645 reply_id: 9750[/import]

Dumb question…how do you test on device?
Meaning, I have profiles for my games, but how do I test every mockup I do other than the simulator? [import]uid: 7856 topic_id: 2645 reply_id: 9757[/import]

I have one of each device. Ask a friend, buy a second hand iPod Touch with same spec as iPhone you want to test against.

For those who want a look ive added a simple demo for controlling a spaceship in space using physics, its a bit rough but all the principles are there

http://developer.anscamobile.com/forum/2010/10/30/moving-object [import]uid: 5354 topic_id: 2645 reply_id: 9760[/import]

What I meant on the device, is about actually installing each ‘prototype’ and/or piece of code to test on actual idevice.
I already have an iPhone 4 and a 2nd gen.

I would like to know how to build to run and which oriole to use.

Or do you have to create a profile for each each piece you want to test.

Sorry againfor the dumb question, maybe a link explaining will suffice, right now on phone socan spend too much time searching.

Thanks,
RD [import]uid: 7856 topic_id: 2645 reply_id: 9769[/import]

nice thanks! [import]uid: 10062 topic_id: 2645 reply_id: 9777[/import]

Does the video on how to get an app to the iPhone help?

http://www.anscamobile.com/resources/videos/

Then just drop the file that was created for you onto the itunes icon. I think that should work. [import]uid: 10062 topic_id: 2645 reply_id: 9778[/import]

What I did is made a pov profile called coronatestapp then anytime I need to test on device I select it in the build process then delete the old one from the phone and from iTunes then drag the new one to iTunes and sync phone then reuse it for the next
Time [import]uid: 7911 topic_id: 2645 reply_id: 9779[/import]

I use Xcode Organiser to quickly add the app to the phone in a matter of seconds. Works REALLY well.

In terms of building, until it’s ready to go I use the Team Provisioning Profile :slight_smile:

// red. [import]uid: 7143 topic_id: 2645 reply_id: 9785[/import]

Thanks guys.
@reddotinc, that’s what I was looking after :wink:

Thanks.
RD [import]uid: 7856 topic_id: 2645 reply_id: 9791[/import]

Hey Gang! Just read/skimmed through this whole thread. Nice to see all the exGS enthusiasm. I’m still going through as much reading as I can while tinkering around with my new subscription :wink:

Just a quick question. Did I miss the link to the webinar video or was it not posted yet. :slight_smile:

-josh

(formerly Jweaver911 exGS user) [import]uid: 10361 topic_id: 2645 reply_id: 10332[/import]

welcome
as far as i know hes still working on it [import]uid: 7911 topic_id: 2645 reply_id: 10336[/import]

Yeah, I’m really looking foward to seeing the webinar video… Any news Carlos?

Cheers
Ace [import]uid: 9899 topic_id: 2645 reply_id: 10356[/import]