I am trying to create a function that will say "if object.x == -10" then " life = life - 1" How can I do this?
Label: corona android iphone ipad building error inmobi problem display screen View image tableView failed object physics touch button game lua config event listener |
Collisions
Like this?
1 2 3 4 5 6 7 | function hitBadStuff(obj) if obj.x <= -10 then life = life -1 end end hidBadStuff(obj) |
I've got a routine that will calculate the exact distance between two objects regardless of the angle between them which is better if you're not restricting your movement to just the x axis.
One thing that you need to know is the size of your objects.
1 2 3 4 5 | local xdist=obj1.x-obj2.x local ydist=obj1.y-obj2.y if ((xdist*xdist)+(ydist*ydist)) <= 20 then -- Check for collision. life = life -1 -- decrease life end |
views:1340 update:2011/10/5 8:48:05
热门文章
GameCenter LeaderBoards and Achievements Enabled Through OpenFeint
send message and call to a person
Forum: Report Spam + PM
[INSTALL_PARSE_FAILED_NO_CERTIFICATES]
[SOLVED] Director ERROR: Failed to execute new( params ) function on 'screen1'
Too many (200) local variables
Corona SVG Level Builder released. Drag and drop physics level editor with Inkscape and SVG.
Small bug in Collectible Items example
Pivot Joints and apparent elasticity
Can't make removeSelf() delayed
send message and call to a person
Forum: Report Spam + PM
[INSTALL_PARSE_FAILED_NO_CERTIFICATES]
[SOLVED] Director ERROR: Failed to execute new( params ) function on 'screen1'
Too many (200) local variables
Corona SVG Level Builder released. Drag and drop physics level editor with Inkscape and SVG.
Small bug in Collectible Items example
Pivot Joints and apparent elasticity
Can't make removeSelf() delayed
相关文章
Debugging device crashes
Gravity at one point
File size of apk file - over 17mb! Can I reduce this?
Inserting the same object
Please help with a string.gmatch problem I'm having
Can't make removeSelf() delayed
Clock Cannon launching June 16th!
Question about "Angry Bird catapult like from simple pool example"
Local variables and methods in object factory module
Money Making Idea for Corona SDK Devs
Gravity at one point
File size of apk file - over 17mb! Can I reduce this?
Inserting the same object
Please help with a string.gmatch problem I'm having
Can't make removeSelf() delayed
Clock Cannon launching June 16th!
Question about "Angry Bird catapult like from simple pool example"
Local variables and methods in object factory module
Money Making Idea for Corona SDK Devs
corona forums © 2003-2011