Cheat Engine Forum Index Cheat Engine
The Official Site of Cheat Engine
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 


Basic Animation Uisng CE GUI and Lua Script

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> Cheat Engine Tutorials -> LUA Tutorials
View previous topic :: View next topic  
Author Message
Corroder
Grandmaster Cheater Supreme
Reputation: 75

Joined: 10 Apr 2015
Posts: 1667

PostPosted: Mon May 20, 2019 9:22 pm    Post subject: Basic Animation Uisng CE GUI and Lua Script Reply with quote

Hi, there.

Wanna make an animation for your hack trainer or for others purpose?.
Here a simple code on a primitive way, to make an animation using CE GUI and Lua scripting.

Have to do before you start.
1. Have a GIF picture
2. Split the GIF picture into several PNG pictures format. (Use online for the best and auto result, just google it)
3. Prepare for a background image.
4. Prepare an XM/WAV sound effect/music. (Considering file size)

Example Code:

Code:
f = createForm()
f.setSize(500,250)
f.Position = 'poScreenCenter'
f.Caption = 'CRDR - Basic Animation Concept'

pnl = createPanel(f)
pnl.setSize(500,175)
pnl.setPosition(0,0)

bgrImg = createImage(pnl)
bgrImg.setSize(500,175)
bgrImg.setPosition(0,0)
bgrImg.Align = 'alClient'
bgrImg.Picture.loadFromStream(findTableFile('bgr.jpg').Stream)
bgrImg.Stretch = true

sonic = createImage(pnl)
sonic.setSize(200,200)
sonic.stretch = true
sonic.setPosition(-100,-13)

rat = createImage(pnl)
rat.setSize(100,100)
rat.stretch = true
rat.setPosition(5,50)

btn = createToggleBox(f)
btn.setSize(100,50)
btn.setPosition(10,185)
btn.caption = 'Start'

label1 = createLabel(f)
label1.Left = 127
label1.Top = 190
label1.Caption = '< Increase Speed'

label2 = createLabel(f)
label2.Left = 387
label2.Top = 190
label2.Caption = 'Decrease Speed >'

trb = createTrackBar(f)
trb.setSize(370,50)
trb.Top = 210
trb.Left = 120
trb.Max = 500
trb.Min = 0
trb.Position = 100
trb.SelStart = 0
trb.ScalePos = 'trTop'

---------------------------------------------------------SONIC
function hack1()
 sndfile=findTableFile('CHICK.XM')
 if (checkbox_getState(btn) == 1) then
  if xmplayer_isPlaying() == true then
   xmplayer_resume()
  else
   xmplayer_playXM(sndfile)
  end
  t.enabled = true
  t2.enabled = true
  btn.caption = 'Stop'
 else
  xmplayer_pause()
  t.enabled = false
  t2.enabled = false
  btn.caption = 'Start'
 end
end

t = {}
t[1] = 'frame_000.png'
t[2] = 'frame_001.png'
t[3] = 'frame_002.png'
t[4] = 'frame_003.png'
t[5] = 'frame_004.png'
t[6] = 'frame_005.png'
t[7] = 'frame_006.png'
t[8] = 'frame_007.png'
t[9] = 'frame_008.png'
t[10] = 'frame_009.png'
t[11] = 'frame_010.png'
t[12] = 'frame_011.png'
t[13] = 'frame_012.png'
t[14] = 'frame_013.png'
t[15] = 'frame_014.png'
t[16] = 'frame_015.png'
t[17] = 'frame_016.png'
t[18] = 'frame_017.png'
t[19] = 'frame_018.png'
t[20] = 'frame_019.png'

pics={}

for i=1,20 do  --- 4 is the total number of your pictures
  pics[i]=createPicture()
  pics[i].loadFromStream(findTableFile(t[i]).Stream)
end

pics.currentPicture=1

function t_tick()
 x,y = sonic.getPosition()
 x = x + 5 ------ delete this line if not want change position
 sonic.Picture=pics[pics.currentPicture]
 pics.currentPicture=(pics.currentPicture % 20)+1  -- carefull here
  if x >= f.width then
  sonic.setPosition(-100,-13)
  x,y = sonic.getPosition()
  x = x + 5
 else
  sonic.setPosition(x,y)
 end
end

t = createTimer()
t.interval = 200
t.enabled = false
t.onTimer = t_tick

-------------------------------------------------------------RAT
t2 = {}
t2[1] = 'frame_01.png'
t2[2] = 'frame_02.png'
t2[3] = 'frame_03.png'
t2[4] = 'frame_04.png'

pics2={}

for i2=1,4 do
  pics2[i2]=createPicture()
  pics2[i2].loadFromStream(findTableFile(t2[i2]).Stream)
end

pics2.currentPicture=1

function t_tick2()
 x2,y2 = rat.getPosition()
 x2 = x2 + 5 ------ delete this line if not want change position
 rat.Picture=pics2[pics2.currentPicture]
 pics2.currentPicture=(pics2.currentPicture % 4)+1  -- carefull here
  if x2 >= f.width then
  rat.setPosition(5,50)
  x2,y2 = rat.getPosition()
  x2 = x2 + 5
 else
  rat.setPosition(x2,y2)
 end
end

t2 = createTimer()
t2.interval = 100
t2.enabled = false
t2.onTimer = t_tick2

--============================================---
function trbChange(sender)
 r = trb.position
 t.interval = r
 t2.interval = r
end

function exit()
 xmplayer_stop()
 closeCE()
 return caFree
end

f.show()
btn.onChange = hack1
trb.onChange = trbChange
f.onClose = exit



CT Source file download (Copy paste URL link below to your web browser):
https://mega.nz/#!3kkVAIYZ!oEPq3Hk2EXoq7fMIHBxKASLO21f6ejkcbhpk-d4iIQY

Demo video:
https://youtu.be/PRzhMifb-Yo


Have funs...

_________________
Stealing Code From Stolen Code...
And Admit It.. Hmmm....Typically LOL
Back to top
View user's profile Send private message
AylinCE
Grandmaster Cheater Supreme
Reputation: 31

Joined: 16 Feb 2017
Posts: 1234

PostPosted: Tue May 21, 2019 6:57 am    Post subject: Reply with quote

Good work, man.
on stage again with a different code.
Your: I will stick to the previous 2 animation code.
I mean gifs that are "forward-back" and "frame_001".


Thank you for your efforts on these issues.

_________________
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
Back to top
View user's profile Send private message Visit poster's website MSN Messenger
ProB1
Advanced Cheater
Reputation: 0

Joined: 20 Jul 2019
Posts: 77
Location: At Home

PostPosted: Tue Jul 23, 2019 6:04 am    Post subject: Reply with quote

Nice Work Gui Cool Shocked Rolling Eyes
Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    Cheat Engine Forum Index -> Cheat Engine Tutorials -> LUA Tutorials All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You cannot download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group

CE Wiki   IRC (#CEF)   Twitter
Third party websites