Adding Projectiles to the User

What I'm working on is a way to add projectiles to the user as they reach certain scores.

I'm using the Implementing a Health Status Bar in Corona SDK found here
http://omnigeek.robmiracle.com/2011/05/30/implementing-a-health-status-bar-in-corona-sdk/

So I have it all set up and it works fine, now what I did is they start off with 2 maxLives and as they reach scores a gamelife and the maxlives increase, but this way I get an error- corona sdk attempt to concatenate upvalue on orbshot **the line referenced is: local projectile = display.newImage( ""..orbshot.."" )

which I would think the orbdensity on the line above it would cause this error first.

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
function newProjectile() 
 
print("maxLives:"..maxLives)
 
        if maxLives == 2 then
            local orbshot = "imagesGame/cinderblock.png"
            local orbdensity = 1
        end
        if maxLives == 3 then
             local orbshot ="imagesGame/tire.png" 
             local orbdensity = 1.5 
              
        end
        if maxLives == 4 then
             local orbshot ="imagesGame/tirelooseicon.png" 
             local orbdensity = 1
              
        end 
        if maxLives == 5 then
             local orbshot ="imagesGame/tirelooseicon.png" 
             local orbdensity = 1
              
        end      
 
                         local projectileDensity = orbdensity
                     local projectile = display.newImage( ""..orbshot.."" )
                     game:insert( projectile )
                     physics.addBody( projectile, { density=projectileDensity, friction=0.7, bounce=0.2} )            
                     orb=projectile
            
                      orb.myName = "orb";
                      orb.bodyType = "kinematic";
                      orb.x = 85;
                      orb.y = _H ;
                      orb.linearDamping = 0.3  ;                 
                      orb.angularDamping = 0.8 ;               
                      orb.isBullet = true 
                transition.to(orb, {time=600, y=_H - 70, transition = easingx.easeOutElastic});
 
        return orb;
end
views:1856 update:2012/1/11 9:01:14
corona forums © 2003-2011