Sorry but I need help again. I have a scrolling background. The player can click anywhere on the screen and my ninja will move to that touch event. I need the ninja to not be able to go off of the screen. Does anyone have an advise for how I would be able to do this? [import]uid: 49863 topic_id: 18612 reply_id: 318612[/import]
It sounds to me you just want to keep character on screen try this:
Obviously your numbers will be different depending on your character size and how your app is running landscape or portrait and which device but this will give you an idea.
[lua]-- Keep Character on Screen
local function keeponscreen (event)
– YourCharacter
if YourCharacter.x < 40 then
YourCharacter.x = 40
end
if YourCharacter.x > 300 then
YourCharacter.x = 300
end
if YourCharacter.y < 30 then
YourCharacter.y = 30
end
if YourCharacter.y > 450 then
YourCharacter.y = 450
end
end
Runtime:addEventListener(“enterFrame”, keeponscreen) [import]uid: 30314 topic_id: 18612 reply_id: 71473[/import]