Sprite falling off screen question

2 questions.

I have a sprite, how would I give it its own local title?

Ex.

1
2
3
local data = require("mysprite").getSpriteSheetData();
local sheet = sprite.newSpriteSheetFromData("mysprite.png",data);
local set = sprite.newSpriteSet(sheet, 1, 16);

I can't see where exactly gameover is defined but yes, that would work.

To give a sprite it's own name see here; http://developer.anscamobile.com/reference/index/spritenewsprite

To "give it a function" try this;

1
2
3
4
local function touchSprite ()
  print "I touched the sprite!"
end
spriteName:addEventListener("touch", touchSprite)

Thank you for the response, any chance you could show me how to incorporate the code I posted into the code you suggested? I've been messing around with it for about an hour and keep getting errors and I'm not sure why : (

Thanks again
-Andrew

Hey Andrew,

What errors are you getting?

I check in fairly regularly and will be more than happy to attempt to help you solve your problem (although it appears you're maybe using a third party tool for sprites?) however if you are in a hurry or need fully coded examples, check here; http://www.anscamobile.com/corona/support/

Otherwise, let me know what errors you're actually getting in the terminal :)

Peach

Thanks for the response. I'd love to get support help but I'd have to save for 2-3 weeks in order to pay for the minimum support, and don't really have the option to do that at the moment : /

The error I'm getting is:
"Director Class - ERROR

Director ERROR: Failed to load 'titlescreen' -
Please check if the file exists and it is correct."

I've noticed that I only get that error if I input:

1
2
3
4
5
6
local checkSprite = function(event)
sprite.y > then rect.y then
gameover()
end
 
Runtime:addEventListener("enterFrame", checkSprite)
views:1682 update:2011/10/18 15:01:22
corona forums © 2003-2011