Hello,
How do I remove this display type?
It returns an event.target, but I can’t seem to remove it so when i go to another screen the image stays visible.
Thanks for reading. [import]uid: 100901 topic_id: 33268 reply_id: 333268[/import]
Hello,
How do I remove this display type?
It returns an event.target, but I can’t seem to remove it so when i go to another screen the image stays visible.
Thanks for reading. [import]uid: 100901 topic_id: 33268 reply_id: 333268[/import]
Towards the top of your program (above your display.loadRemoteImage() call back:
local downloadedImage
then in your callback where you can set the X, and Y of the downloaded image;
downloadedImage = event.target
Now downloadImage is a reference to the display object that you can use to your heart’s content.
Doing lots of images? Make downloadedImage an array.
Edited to add:
If you put it in a display group that gets removed, then that will take care of your removal. In particular if you’re using storyboard, make sure to put into the scene’s view:
scene.view:insert(event.target)
-- or if you're in one of the functions that creates "group", i.e. group = self.view then just do a
-- group:insert(event.target)
Then you don’t have to keep track of it.
[import]uid: 19626 topic_id: 33268 reply_id: 132196[/import]
Cool thanks, for the explanation.
This will go in to my little help text file with code hints.
[import]uid: 100901 topic_id: 33268 reply_id: 132197[/import]
Towards the top of your program (above your display.loadRemoteImage() call back:
local downloadedImage
then in your callback where you can set the X, and Y of the downloaded image;
downloadedImage = event.target
Now downloadImage is a reference to the display object that you can use to your heart’s content.
Doing lots of images? Make downloadedImage an array.
Edited to add:
If you put it in a display group that gets removed, then that will take care of your removal. In particular if you’re using storyboard, make sure to put into the scene’s view:
scene.view:insert(event.target)
-- or if you're in one of the functions that creates "group", i.e. group = self.view then just do a
-- group:insert(event.target)
Then you don’t have to keep track of it.
[import]uid: 19626 topic_id: 33268 reply_id: 132196[/import]
Cool thanks, for the explanation.
This will go in to my little help text file with code hints.
[import]uid: 100901 topic_id: 33268 reply_id: 132197[/import]
I have some problem. I follow the above procedure. when i goto next scene before loading the image, that time the image will appear in next scene in (0,0) position and i am getting the below error
index.lua:140: attempt to call method ‘insert’ (a nil value)
stack traceback:
[C]: in function ‘insert’
…/Documents/GIT Projects/shadowcharquiz/src/index.lua:140: in function <…/Documents/GIT Projects/shadowcharquiz/src/index.lua:127>
(tail call): ?
?: in function <?:463>
Runtime error: …/Documents/GIT Projects/shadowcharquiz/src/index.lua:140: attempt to call method ‘insert’ (a nil value)
stack traceback:
[C]: in function ‘insert’
…/Documents/GIT Projects/shadowcharquiz/src/index.lua:140: in function <…/Documents/GIT Projects/shadowcharquiz/src/index.lua:127>
(tail call): ?
?: in function <?:463>
How to solve this one?
You must cancel request when changing scene. Because request is send and while it’s trying to load you destroy scene by changing it. When request is ready it tries to insert image into scene which is no longer there. You cancel all requests or give condition to insert into scene if this scene is different from nil (if it still exists)
I have some problem. I follow the above procedure. when i goto next scene before loading the image, that time the image will appear in next scene in (0,0) position and i am getting the below error
index.lua:140: attempt to call method ‘insert’ (a nil value)
stack traceback:
[C]: in function ‘insert’
…/Documents/GIT Projects/shadowcharquiz/src/index.lua:140: in function <…/Documents/GIT Projects/shadowcharquiz/src/index.lua:127>
(tail call): ?
?: in function <?:463>
Runtime error: …/Documents/GIT Projects/shadowcharquiz/src/index.lua:140: attempt to call method ‘insert’ (a nil value)
stack traceback:
[C]: in function ‘insert’
…/Documents/GIT Projects/shadowcharquiz/src/index.lua:140: in function <…/Documents/GIT Projects/shadowcharquiz/src/index.lua:127>
(tail call): ?
?: in function <?:463>
How to solve this one?
You must cancel request when changing scene. Because request is send and while it’s trying to load you destroy scene by changing it. When request is ready it tries to insert image into scene which is no longer there. You cancel all requests or give condition to insert into scene if this scene is different from nil (if it still exists)