curse:
ill post parts of my code, with explantation, in the same order:
my soldat, i the main character:
local soldat = display.newImage("soldat.png") soldat.x = \_W/2 soldat.y = \_H/2 soldat.rotation = 0
then the soldat function, to rotate the guy - he can rotate above the aiming image, if he likes:
function touched(event) if(event.phase == "began" or event.phase == "moved") then angle = math.deg(math.atan2((event.y-soldat.y),(event.x-soldat.x))) soldat.rotation = angle +90 end end
bg:addEventListener(“touch”, touched)
followed by the enemy function:
local enemypics = {"zombiebrain.png","zombieeye.png","buggreen.png"} function spawnEnemy() local enemy = display.newImage(enemypics[math.random (#enemypics)]) enemy:addEventListener("tap", smash) if math.random(2) == 1 then enemy.x = math.random(-100, -10) -- enemy.y = math.random(10, 100) else enemy.x = math.random ( \_H + \_W ) enemy.xScale = 0 end enemy.y = math.random (\_W + \_H) enemy.trans = transition.to (enemy, {x=centerX, y=centerY, time=3000, onComplete=hitPlanet } ) speedBump = speedBump + 1 angle = math.deg(math.atan2((soldat.y-enemy.y),(soldat.x-enemy.x))) enemy.rotation = angle +90 end getTimer = timer.performWithDelay(900+Rand, spawnEnemy, numbEnemy+Rand)
 and the image, wich should be over everything else:
local soldatlicht = display.newGroup() soldatlicht:insert(lichtkranz) soldatlicht:insert(soldat) soldatlicht:insert(black) local verlauf = display.newImage("verlauf.png") verlauf.anchorX = 0.5 verlauf.anchorY = 0.5 verlauf.x = \_W/2 verlauf.y= \_H/2 soldatlicht:insert(verlauf)
the “soldat” function works correct, if i change the X and Y of his position, he is covered by the “verlauf” (- in englich: gardien)
but all enemypics and enemy´s are not.
i tried to put them into a group, but “enemy” didnt works and “enemypics” gave me an error