Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- by default, Sprites do not have a height or width or even an image
- Def.Sprite{
- OnCommand=function(self)
- --declare our variables
- local song, path, width, height;
- -- get the current song as a song object
- song = GAMESTATE:GetCurrentSong();
- -- if there is a song (if the variable is not nil) then...
- if song then
- -- then get that song's banner path
- -- if the banner path is empty, path will be an empty string like (but not nil)
- path = song:GetBannerPath();
- -- path shouldn't be nil, but check just in case
- if path then
- -- in this context, self is the Sprite object we are in
- -- we haven't loaded any image yet
- -- so use the Load() method and give it the path from above
- self:Load(path);
- -- now that we've loaded the image, it should have height and width
- width = self:GetWidth();
- height = self:GetHeight();
- -- do stuff with height and width now
- end
- end
- end
- };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement