Some suggestions?
Thank you.
[import]uid: 162818 topic_id: 30456 reply_id: 330456[/import]
Some suggestions?
Thank you.
[import]uid: 162818 topic_id: 30456 reply_id: 330456[/import]
Not sure if this is the best way to do it, but I would remove the first image and replace it with the second image.
[lua]-- display a red square
local square = display.newImageRect(âred.pngâ,500,500 )
â function to change image
function changeSquare()
display.remove( square )
square = display.newImageRect(âblue.pngâ,350,350 )
end
â timer that calls function to change image.
timer.performWithDelay(2500, changeSquare)[/lua] [import]uid: 62706 topic_id: 30456 reply_id: 122024[/import]
If you donât want to lose the original object, I done it using graphics.newImageSheet and display.newSprite.
local options =
{
-- The params below are required
width = 80,
height = 80,
numFrames = 3,
-- The params below are optional; used for dynamic resolution support
sheetContentWidth = 240, -- width of original 1x size of entire sheet
sheetContentHeight = 80 -- height of original 1x size of entire sheet
}
local imageSheet = graphics.newImageSheet( "pucks.png", options )
-- Sequence data for pucks in sprite sheet
local sequenceData = {
{ name="round", start=1, count=1 },
{ name="tri", start=2, count=1 },
{ name="star", start=3, count=1 }
}
Puck = display.newSprite( imageSheet, sequenceData )
if ICEpuckShape == "round" then
Puck:setSequence( "round" )
elseif ICEpuckShape == "triangle" then
Puck:setSequence( "tri" )
elseif ICEpuckShape == "star" then
Puck:setSequence( "star" )
end
Dave [import]uid: 117617 topic_id: 30456 reply_id: 122028[/import]
Iâll try your suggestions then let a feedback, guys.
Thanks.
[import]uid: 162818 topic_id: 30456 reply_id: 122042[/import]
I think what you are looking for is exactly this:
transition.dissolve( "image1.png", "image2.png", 2000, 0 )
transforms image1 to image2 in 2 secs with 0 delay via dissolving the first image to the second. [import]uid: 170210 topic_id: 30456 reply_id: 122054[/import]
I got it, guys! Thanks! Thanks! =D [import]uid: 162818 topic_id: 30456 reply_id: 122055[/import]
Wow! I really liked that, adiltemiz! Sounds a very good idea.
Thanks. [import]uid: 162818 topic_id: 30456 reply_id: 122056[/import]
Didnât realise you could that with transitions, how does it know what image1.png and image2.png are ?
I searched for ages when I wanted to change the image of a display object and saw movieclip was the recommended way but doesnât support scaling.
Dave [import]uid: 117617 topic_id: 30456 reply_id: 122058[/import]
you are welcome carmo:)
Dave, if you put image1.png and image2.png in the same folder with main.lua, it automatically finds the images. Actually I recommend to put all image files under a new folder named images. If you are planning to resize the raw image to the format you want you should first load the image by display.newImage and rescale it and then use its pointer in the transition function. I hope it helps, if you need a piece of code let me know. [import]uid: 170210 topic_id: 30456 reply_id: 122120[/import]
Can you then keep the same display object and change itâs image using this ?
Dave [import]uid: 117617 topic_id: 30456 reply_id: 122138[/import]
Not sure if this is the best way to do it, but I would remove the first image and replace it with the second image.
[lua]-- display a red square
local square = display.newImageRect(âred.pngâ,500,500 )
â function to change image
function changeSquare()
display.remove( square )
square = display.newImageRect(âblue.pngâ,350,350 )
end
â timer that calls function to change image.
timer.performWithDelay(2500, changeSquare)[/lua] [import]uid: 62706 topic_id: 30456 reply_id: 122024[/import]
If you donât want to lose the original object, I done it using graphics.newImageSheet and display.newSprite.
local options =
{
-- The params below are required
width = 80,
height = 80,
numFrames = 3,
-- The params below are optional; used for dynamic resolution support
sheetContentWidth = 240, -- width of original 1x size of entire sheet
sheetContentHeight = 80 -- height of original 1x size of entire sheet
}
local imageSheet = graphics.newImageSheet( "pucks.png", options )
-- Sequence data for pucks in sprite sheet
local sequenceData = {
{ name="round", start=1, count=1 },
{ name="tri", start=2, count=1 },
{ name="star", start=3, count=1 }
}
Puck = display.newSprite( imageSheet, sequenceData )
if ICEpuckShape == "round" then
Puck:setSequence( "round" )
elseif ICEpuckShape == "triangle" then
Puck:setSequence( "tri" )
elseif ICEpuckShape == "star" then
Puck:setSequence( "star" )
end
Dave [import]uid: 117617 topic_id: 30456 reply_id: 122028[/import]
Iâll try your suggestions then let a feedback, guys.
Thanks.
[import]uid: 162818 topic_id: 30456 reply_id: 122042[/import]
I think what you are looking for is exactly this:
transition.dissolve( "image1.png", "image2.png", 2000, 0 )
transforms image1 to image2 in 2 secs with 0 delay via dissolving the first image to the second. [import]uid: 170210 topic_id: 30456 reply_id: 122054[/import]
I got it, guys! Thanks! Thanks! =D [import]uid: 162818 topic_id: 30456 reply_id: 122055[/import]
Wow! I really liked that, adiltemiz! Sounds a very good idea.
Thanks. [import]uid: 162818 topic_id: 30456 reply_id: 122056[/import]
Didnât realise you could that with transitions, how does it know what image1.png and image2.png are ?
I searched for ages when I wanted to change the image of a display object and saw movieclip was the recommended way but doesnât support scaling.
Dave [import]uid: 117617 topic_id: 30456 reply_id: 122058[/import]
you are welcome carmo:)
Dave, if you put image1.png and image2.png in the same folder with main.lua, it automatically finds the images. Actually I recommend to put all image files under a new folder named images. If you are planning to resize the raw image to the format you want you should first load the image by display.newImage and rescale it and then use its pointer in the transition function. I hope it helps, if you need a piece of code let me know. [import]uid: 170210 topic_id: 30456 reply_id: 122120[/import]
Can you then keep the same display object and change itâs image using this ?
Dave [import]uid: 117617 topic_id: 30456 reply_id: 122138[/import]