I’m having a problem with the display object enemy. When I click on the enemy, the enemy.width and enemy.height are distorted and gives values like memory addresses like 107786192. What is the problem here and what am I doing wrong?
[lua] function enemy:touch ( event )
if (event.phase == “ended”) then
if (self.direction == “FROM_LEFT” or self.direction == “FROM_RIGHT”) then
self.speed = 0
end
self:prepare( “die” )
self:play()
–enemy.width and enemy.height is true here
end
return true
end
function enemy:enterFrame ( event )
–enemy.width and enemy.height is giving non-sense values here after touch
if (self.sequence == “die” and self.currentFrame == numOfFrames) then
if (self.direction == “FROM_AIR_LEFT” or self.direction == “FROM_AIR_RIGHT”) then
if (self.y >= display.contentHeight - self.height / 2) then
killEnemy( self )
end
else
killEnemy( self )
end
else
if (self.direction == “FROM_LEFT”) then
if (self.x <= display.contentCenterX - self.width) then
self.x = self.x + self.speed
end
elseif (self.direction == “FROM_RIGHT”) then
if (self.x >= display.contentCenterX + self.width) then
self.x = self.x + self.speed
end
elseif (self.direction == “FROM_AIR_LEFT”) then
if (self.y <= display.contentHeight - self.height / 2) then
self.y = self.y + self.speed
end
elseif (self.direction == “FROM_AIR_RIGHT”) then
if (self.y <= display.contentHeight - self.height / 2) then
self.y = self.y + self.speed
end
end
end
end
enemy:addEventListener( “touch”, enemy )
Runtime:addEventListener( “enterFrame”, enemy )[/lua] [import]uid: 154911 topic_id: 31231 reply_id: 331231[/import]