Hello Again,
I´m quite in the final steps of my first game but can’t figure out one thing, which is rather important 
I have a set up of different creatures and items which the player catches. I would like to achieve the situation where the player must catch those creatures and items in order or related to each other.
A simple example:
If you catch a bee you lose 10 points, but if you catch a star before it and then catch a bee you gain 10 points + the state is dropped, meaning if you catch another bee you lose 10 points again, unless you catch a star first.
Here would be the code where I drop one item:
[lua]–***************************************************
– BEE CREATION, COLLISION & DROP
–***************************************************
local onbeeCollision = function( self, event )
if (event.other.myName == “tongue” and event.target.myName == “bee” or event.other.myName == “ground”) then
local doCollision = function()
audio.play( bugCaughtSound )
self.isHit = true
print( “bee destroyed!”)
self.isVisible = false
self.isBodyActive = false
eatenBug.x = self.x; eatenBug.y = self.y
eatenBug.alpha = 0
eatenBug.isVisible = true
local fadebug = function()
transition.to( eatenBug, { time=500, alpha=0 } )
end
transition.to( eatenBug, { time=50, alpha=1.0, onComplete=fadebug } )
timer.performWithDelay( 50, resetTongue )
self.parent:remove( self )
self = nil
end
–COLLISION TIMER
local collisionTimer = timer.performWithDelay( 1, doCollision, 1 )
if event.other.myName == “character” then
bugCount = bugCount + 1
bugText.text = "Catched: " … tostring( bugCount )
bugText.xScale = 0.5; bugText.yScale = 0.5
bugText.x = (480 - (bugText.contentWidth * 0.5)) - 15
bugText.y = 305
print(“bee caught”)
local newScore = gameScore + 2
setScore( newScore )
elseif event.other.myName == “tongue” then
bugCount = bugCount + 1
bugText.text = "Caught: " … tostring( bugCount )
bugText.xScale = 0.5; bugText.yScale = 0.5
bugText.x = (480 - (bugText.contentWidth * 0.5)) - 15
bugText.y = 305
print(“bee caught”)
local newScore = gameScore -10
setScore( newScore )
elseif event.other.myName == “ground” then
print(“Ground hit!”)
end
end
end
–BEE DROP
local beeDrop = function()
local displayScale = display.contentScaleX
if displayScale < 1 then
beeSheet = sprite.newSpriteSheet( “images/beeSprite@2x.png”, 130, 120 )
else
beeSheet = sprite.newSpriteSheet( “images/beeSprite.png”, 65, 60 )
end
local spriteSet1 = sprite.newSpriteSet(beeSheet, 1, 2)
sprite.add( spriteSet1, “move”, 1, 2, 100, 0 )
bee = sprite.newSprite( spriteSet1 )
if displayScale < 1 then
bee.xScale = .5; bee.yScale = .5
end
bee.x = display.contentWidth / 2
bee.y = display.contentHeight / 2
bee:prepare(“move”)
bee:play()
bee.x = mRand( 80, 450 ); bee.y = -40
transition.to( bee, { time=mRand(1500, 2000), y = 400, transition=easing.linear } )
bee.isHit = false
physics.addBody( bee, “dynamic”,{ density=beeDensity, bounce=0, friction=0.5, shape=bugShape } )
bee.isFixedRotation = true
bee.myName = “bee”
gameGroup:insert( bee )
bee.postCollision = onbeeCollision
bee:addEventListener( “postCollision”, bee )
counter:toFront()
pauseBtn:toFront()
scoreText:toFront()
bugText:toFront()
end
– CREATE NEW BEE
local beeTimer = function()
startDrop = timer.performWithDelay( mRand(1000, 1500), beeDrop, 0 )
end[/lua]
Any help or hints would be super!
Thanks,
Gert
[import]uid: 105289 topic_id: 30558 reply_id: 330558[/import]


