Jump to content

[TOPIC: topicViewTemplate]
[GLOBAL: userSmallPhoto]
Photo

Tips on Using the API Docs to Fix Your Code
Started by J. A. Whye Aug 09 2013 04:57 PM

12 replies to this topic
[TOPIC CONTROLS]
[/TOPIC CONTROLS]
[modOptionsDropdown]
[/modOptionsDropdown]
[reputationFilter]
[TOPIC: post.html]
#1

J. A. Whye

[GLOBAL: userInfoPane.html]
J. A. Whye
  • Corona Geek

  • 1,687 posts
  • Corona SDK

While asking questions in the forums is a completely legit way to find the answer to a problem, it should probably be at least the third thing you try. 

 

In order they are:

 

1. Look for the answer in the API documentation.

 

2. Bang your head against the info you find there.

 

3. Ask on the forums if you still don't get it.

 

The documentation shouldn't scare you -- it's there to help you figure out how to create great games and apps with Corona SDK. But I think a lot of people skip that step because there's a LOT of info there and it can sometimes seem overwhelming.

 

So I created a video showing some tips for getting the most out of the Corona SDK API Documentation.

 

I hope it helps!

 

 Jay

 

 

 

 


  • roaminggamer, evanlow, Cing2 and 1 other like this

[TOPIC: post.html]
#2

Rob Miracle

[GLOBAL: userInfoPane.html]
Rob Miracle
  • Moderator

  • 25,147 posts
  • Corona SDK

Thanks Jay.  I've pinned it to the top.  Very well done. 

 

To add to what Jay's video says, please note the two links at the very top:  "Guides" and "Tutorials".  Sometimes you may not know what API call to look for and the Guides and Tutorials can sometimes "guide" you to where you need to go.


  • evanlow and Cing2 like this

[TOPIC: post.html]
#3

Guest_lgalcott_*

[GLOBAL: userInfoPane.html]
Guest_lgalcott_*
  • Guests

Very helpful video.  Great job and thank  you for putting it together.



[TOPIC: post.html]
#4

Guest_sharma.shivam88_*

[GLOBAL: userInfoPane.html]
Guest_sharma.shivam88_*
  • Guests

hello everyone.

recently i have been working on a jigsaw puzzle game.allthough its working fine but i am not 

able to create a timer in the game.this is a small part of my coding.

--there are my variables

puzzlePiecesCompleted = 0
totalPuzzlePieces = 9
puzzlePieceWidth, puzzlePieceHeight = 120, 120
puzzlePieceStartingY = { 80,220,360,500,640,780,920,1060,1200 }
puzzlePieceSlideUp = 140
puzzleWidth, puzzleHeight = 320, 320
puzzlePieces = {}
timeremain = 120
timeup = false
ready = false
 
--my main problem is in enterScene
function scene:enterScene( event )
 
 function countdown(e)
if(timeremain ==120)then
ready = true
displaytext.text="GO"
end
timeremain = timeremain-1
countdown.text = timeremain
if(timeremain==0)then
timeup = true
ready =false
 
 end
 end
 end
 
 local function gametimer()
 if(timeremain ==120)then
 gametmr = timer.performWithDelay(1000,countdown,120)
 end
 ready = false
 end
 
 function scene:exitScene( event )
local function winlose(condition)
if (condition =="win")then
displaytext.text = "win"
elseif (condition=="loose")then
displaytext.text = "loose"
end
 end
end
scene:addEventListener( "createScene", scene )
scene:addEventListener( "enterScene", scene )
scene:addEventListener( "exitScene", scene )
scene:addEventListener( "destroyScene", scene )
 
return scene.....
 
 
i dont know where i am going wrong.
2.)also there is something i am really interested to know about..thats how to we create a box type structure like in candy crush.


[TOPIC: post.html]
#5

Guest_sharma.shivam88_*

[GLOBAL: userInfoPane.html]
Guest_sharma.shivam88_*
  • Guests

is there any software that can help me to break an image into 5X5 square so that i can create jigsaw puzzles??



[TOPIC: post.html]
#6

roaminggamer

[GLOBAL: userInfoPane.html]
roaminggamer
  • Corona Geek

  • 7,463 posts
  • Corona SDK

@Sharma,

 

I see you're hijacking here too.  Don't do this.  You wont' get any help from those of us who posted the original threads.  We posted a topic to talk about that topic, not some random question.

 

You need to ask new questions in new posts.  Any other approach is wrong, will not get answers, and abuses the system to the point that it isn't useful.  

 

Note: Forums are not a place to get answers to your questions.  They are a place to ask for help in such a way that you get help and future readers of your question get help on the same topic you asked about.  

 

Please go back and delete all posts where you hijacked someone else's thread with an unrelated post.  Then, do it right.  

 

These are threads you hijacked in (go click the delete button on your posts):


  • schroederapps and simon.natt like this

[TOPIC: post.html]
#7

Rob Miracle

[GLOBAL: userInfoPane.html]
Rob Miracle
  • Moderator

  • 25,147 posts
  • Corona SDK

Please do not post in random threads as @roaminggamer asked. Also do not post the same question in multiple places. If you cannot find an appropriate thread to post on, create a new one.

 

For anyone with a desire to answer these hijacked threads, please do not. I don't want to lock these threads but if they continue off topic, I won't have a choice.

 

Thanks

Rob



[TOPIC: post.html]
#8

jeremy75

[GLOBAL: userInfoPane.html]
jeremy75
  • Enthusiast

  • 45 posts
  • Corona SDK

I am finding the documentation pretty dreadful!

 

For example on this page;-

https://docs.coronalabs.com/guide/media/displayObjects/index.html

 

It introduces display objects, and while saying they are all the same it fails to effectively tell you what the parameters are.

An example on that page is;-

local square = display.newRect( myGroup, 0, 0, 100, 100 ) --red square is at the bottom
square:setFillColor( 1, 0, 0 )
local circle = display.newCircle( myGroup, 80, 120, 50 )

It doesn't mention what the 4 numbers are for a rectangle or why there are 3 for circle, what order they are (if you guessed them) and which display objects have which parameters.

 

Honestly, i have spent quite alot of time searching for parameter information on various methods. 

 

I usually have to find the answers elsewhere.

 

Where there are links, on specific methods you end up on pages like this... which STILL don't give any information about method parameters!!!

https://docs.coronalabs.com/api/library/display/newGroup.html

 

 

... EDIT - I want to check the parameters for setFillColor so i used the search on docs.coronalabs etc

 

I went to Display Objects again which showed only this example

local square = display.newRect( myGroup, 0, 0, 100, 100 ) --red square is at the bottom
square:setFillColor( 1, 0, 0 )
local circle = display.newCircle( myGroup, 80, 120, 50 ) --green circle is in the middle
circle:setFillColor( 0, 1, 0 )
local rect = display.newRect( myGroup, 0, 0, 120, 80 ) --blue rectangle is at the top
rect:setFillColor( 0, 0, 1 )

Then clicked on display.newRect (since that is where i am using it)
I went to this page
https://docs.coronalabs.com/daily/api/library/display/newRect.html

 

and the example there shows this 

local myRectangle = display.newRect( 0, 0, 150, 50 )
myRectangle.strokeWidth = 3
myRectangle:setFillColor( 0.5 )
myRectangle:setStrokeColor( 1, 0, 0 )

What on earth are the parameters for setFillColor and how can you navigate to the API documentation for it when a direct search of the method does not show it?

 

Am i doing it wrong? Should i just be searching example code and hope for comments?

 

It is more than frustrating and slowing down development hugely. 



[TOPIC: post.html]
#9

J. A. Whye

[GLOBAL: userInfoPane.html]
J. A. Whye
  • Corona Geek

  • 1,687 posts
  • Corona SDK

Yeah, you're doing it wrong. ;)

 

At the top of that first page you linked there's a section called Creating Display Objects and the pages linked there show the parameters needed for display.newRect, display.newCircle, etc.

 

They can't have EVERYTHING on one page, so if you want the parameters for display.newCircle you need to go to that API page. If you want to see how to use setFillColor you need to go to *that* API page. If every example code snippet explained the parameters for every line of code the focus would be diluted.

 

In general the "Guides" won't give you the details of the API calls -- they show you how the API calls work together to get things done. But for each of those API calls you'll need to dig down to get the details for each one.

 

 

Where there are links, on specific methods you end up on pages like this... which STILL don't give any information about method parameters!!!

https://docs.coronalabs.com/api/library/display/newGroup.html

 

That page shows you every parameter for display.newGroup -- it's just that API call has no parameters. :) So you were on the right track as far as where to look, you just picked a poor example. 

 

Use this page: https://docs.coronalabs.com/api/index.html

 

...when you want to look up an API call. I go there and then just Ctrl/Cmd-F on that page to search for whatever I need.

 

Hopefully that will get you on the right track.

 

 Jay


  • roaminggamer and jeremy75 like this

[TOPIC: post.html]
#10

jeremy75

[GLOBAL: userInfoPane.html]
jeremy75
  • Enthusiast

  • 45 posts
  • Corona SDK

Thank you Jay. I will use your approach from now.



[TOPIC: post.html]
#11

ameliadavies

[GLOBAL: userInfoPane.html]
ameliadavies
  • Observer

  • 7 posts
  • Corona SDK

Thank you so much for sharing this. I didn't know this before.



[TOPIC: post.html]
#12

irfan1.aloha

[GLOBAL: userInfoPane.html]
irfan1.aloha
  • Observer

  • 8 posts
  • Corona SDK

Thanks J. A. Whye for sharing a informative video and your valuable thoughts. Keep It Up!   :)



[TOPIC: post.html]
#13

irfan1.aloha

[GLOBAL: userInfoPane.html]
irfan1.aloha
  • Observer

  • 8 posts
  • Corona SDK

Nice information along with helpful video.

Thanks team!




[topic_controls]
[/topic_controls]