AylinCE Grandmaster Cheater Supreme
Reputation: 35 Joined: 16 Feb 2017 Posts: 1476
|
Posted: Thu Mar 14, 2019 4:22 am Post subject: Re: How to change picture with click of the button? |
|
|
Razi wrote: | How to change picture with click of the button?
3 pictures added with Table menu add an image file. Table created:
Code: | local picturestbl = { [1] = 'pict-1.gif', [2] = 'pict-2.gif', [3] = 'pict-3.gif' } |
How to change pictures with 2 buttons in the CEImage1? If CEButton1 is clicked, then show pict-1.gif, if CEButton2 is clicked, then show pict-2.gif.
How to change pictures with 2 buttons in the UDF1 form with same way?
Can you make a .CT file for example? |
CE still does not support .gif.
You should create a gif with the help of the following code.
How to:
1) .CT "Add File" (create gifi: split into .png and upload to CT)
2) Set picture names: (Example: There are 9 pictures ..
Names: frame_001 .. frame_002 .. frame_003 .. frame_009 etc. )
3) Process the image numbers in the code: For gif1: "for i = 1,9 do"
Example for gif2: "for i = 10,18 do"
4) Give ButtonClick approvals: "gif1.image.stretch = false
gif1.image.Visible = false "or gif2 etc.
Code: | function createGIF(form, width, top, frames, doCenter)
---- ImageGIF Code Creator: FreeER and Corroder Thanks to +1 Rep..
-------------------------------------------------------
local pics={}
for _,frame in pairs(frames) do
local pic
if frame.ClassName == 'TMemoryStream' then
pic = createPicture()
pic.loadFromStream(frame)
else -- first try to load as a tableFile then as a filepath
local file = findTableFile(frame)
if file then
pic = createPicture()
pic.loadFromStream(file.Stream)
else
-- loadFromFile doesn't report success, nor does the Picture object
-- have a way to check, so do it ourselves first.
local function file_exists(name)
local f=io.open(name,"r")
if f~=nil then io.close(f) return true else return false end
end
if file_exists(frame) then
pic = createPicture()
pic.loadFromFile(frame)
end
end
end
-- if successfully loaded then add it
if pic then pics[#pics+1] = pic end
end
-- if we failed to load any frames
if #frames ~= 0 and #pics == 0 then return nil end
pics.currentPicture = 1
local mImage = createImage(form)
mImage.width = width
mImage.top = top
mImage.height = form.height
if doCenter then
mImage.left = (form.width-mImage.width) / 2
end
--mImage.stretch = true
local gif = {}
gif.image = mImage
gif.pics = pics
gif.next = function()
pics.currentPicture = (pics.currentPicture % #pics) + 1
mImage.Picture = pics[pics.currentPicture]
end
gif.timer = createTimer(mImage)
gif.timer.Interval = 3500 / #gif.pics -- frames per second
gif.timer.OnTimer = function(sender) gif.next() end
return gif
end
local frameNameFormat = 'frame_%03d.png'
-- create a gif with frames 1-14, dual flames
local t = {}
for i=1,14 do
t[i] = findTableFile(frameNameFormat:format(i)).Stream
end
gif1 = createGIF(UDF1, UDF1.width, 200, t, true)
-- create a gif with frames 21-38, rainbowy explosion
local t = {}
for i=15,29 do
t[#t+1] = findTableFile(frameNameFormat:format(i)).Stream
end
gif2 = createGIF(UDF2, 30, 30, t, true)
--------------------------------------------------
function CEButton2Click(sender)
gif1.image.stretch = false
gif2.image.stretch = false
gif1.image.Visible = false
gif2.image.Visible = false
end
function CEButton1Click(sender)
gif1.image.stretch = true
gif1.image.Visible = true
end
|
_________________ Hi Hitler Different Trainer forms for you!
https://forum.cheatengine.org/viewtopic.php?t=619279
Enthusiastic people: Always one step ahead
Do not underestimate me Master: You were a beginner in the past
|
|