Hi guys,
I'm wondering if anyone might be kind enough to help me out. I have been working on this for a few days and not getting very far. I am sure it should be simple for a proper scripter.
So, the effect I am trying to create is the kind of thing you might see in an interactive graphic novel. It's kind of like a cutscene but without the video media. I have three images (background, wife and murderer). I am trying to create some parallax scrolling type effect.
I kind of got it to work but it's very messy and I've got it broken into three scripts. I would prefer just one. Anyway here are my bad and messy scripts:
Background:
-- LUA Script - precede every function and global member with lowercase name of script + '_main'
g_myimage = {}
g_mysprite = {}
g_myangle = {}
g_myx = {}
g_myy = {}
function cutscene1_background_init(e)
g_myimage[e] = LoadImage(GetEntityString(e,0))
g_mysprite[e] = 0
g_myangle[e] = 0
g_myx[e] = 0
g_myy[e] = 25
end
function cutscene1_background_main(e)
if g_Entity[e]['plrinzone']==1 then
if cutscenetimer_background == nil then
StartTimer(e)
cutscenetimer_background = 1
end
if GetTimer(e) < 10000 then
FreezePlayer()
else
SendMessageF("unfreezeplayer",0)
end
--FreezeAI()
-- FreezePlayer()
if g_mysprite[e] == 0 then
g_mysprite[e] = CreateSprite ( g_myimage[e] )
end
SetSpriteDepth ( g_mysprite[e], 100 )
aspectratio = GetImageWidth(g_myimage[e]) / GetImageHeight(g_myimage[e])
SetSpriteSize ( g_mysprite[e], 200*aspectratio, 100 )
SetSpriteOffset ( g_mysprite[e], 25*aspectratio, 25 )
SetSpritePosition ( g_mysprite[e], g_myx[e], g_myy[e] )
g_myx[e] = g_myx[e] - 0.01
--g_myangle[e] = g_myangle[e] + 0.1
--SetSpriteAngle( g_mysprite[e], g_myangle[e] )
--SetSpriteColor ( g_mysprite[e], math.random(0,255), math.random(0,255), math.random(0,255), 255 )
end
if GetTimer(e) > 10000 and g_mysprite[e] ~= 0 then
-- Destroy(e)
DeleteSprite ( g_mysprite[e] )
-- SendMessageF("unfreezeai",0)
-- SendMessageF("unfreezeplayer",0)
Destroy(e)
end
-- SendMessageF("unfreezeai",0)
-- SendMessageF("unfreezeplayer",0)
end
Wife:
-- LUA Script - precede every function and global member with lowercase name of script + '_main'
g_myimage = {}
g_mysprite = {}
g_myangle = {}
g_myx = {}
g_myy = {}
function cutscene1_wife_init(e)
g_myimage[e] = LoadImage(GetEntityString(e,0))
g_mysprite[e] = 0
g_myangle[e] = 0
g_myx[e] = 80
g_myy[e] = 25
end
function cutscene1_wife_main(e)
if g_Entity[e]['plrinzone']==1 then
if cutscenetimer_wife == nil then
StartTimer(e)
cutscenetimer_wife = 1
end
--FreezeAI()
--FreezePlayer()
if g_mysprite[e] == 0 then
g_mysprite[e] = CreateSprite ( g_myimage[e] )
end
SetSpriteDepth ( g_mysprite[e], 100 )
aspectratio = GetImageWidth(g_myimage[e]) / GetImageHeight(g_myimage[e])
SetSpriteSize ( g_mysprite[e], 100*aspectratio, 100 )
SetSpriteOffset ( g_mysprite[e], 25*aspectratio, 25 )
SetSpritePosition ( g_mysprite[e], g_myx[e], g_myy[e] )
g_myx[e] = g_myx[e] - 0.08
--g_myangle[e] = g_myangle[e] + 0.1
--SetSpriteAngle( g_mysprite[e], g_myangle[e] )
--SetSpriteColor ( g_mysprite[e], math.random(0,255), math.random(0,255), math.random(0,255), 255 )
end
if GetTimer(e) > 10000 and g_mysprite[e] ~= 0 then
Destroy(e)
DeleteSprite ( g_mysprite[e] )
-- SendMessageF("unfreezeai",0)
-- SendMessageF("unfreezeplayer",0)
end
--SendMessageF("unfreezeai",0)
-- SendMessageF("unfreezeplayer",0)
end
Murderer:
-- LUA Script - precede every function and global member with lowercase name of script + '_main'
g_myimage = {}
g_mysprite = {}
g_myangle = {}
g_myx = {}
g_myy = {}
function cutscene1_murderer_init(e)
g_myimage[e] = LoadImage(GetEntityString(e,0))
g_mysprite[e] = 0
g_myangle[e] = 0
g_myx[e] = 20
g_myy[e] = 25
end
function cutscene1_murderer_main(e)
if g_Entity[e]['plrinzone']==1 then
if cutscenetimer_murderer == nil then
StartTimer(e)
cutscenetimer_murderer = 1
end
--FreezeAI()
-- FreezePlayer()
if g_mysprite[e] == 0 then
g_mysprite[e] = CreateSprite ( g_myimage[e] )
end
SetSpriteDepth ( g_mysprite[e], 100 )
aspectratio = GetImageWidth(g_myimage[e]) / GetImageHeight(g_myimage[e])
SetSpriteSize ( g_mysprite[e], 90*aspectratio, 90 )
SetSpriteOffset ( g_mysprite[e], 25*aspectratio, 25 )
SetSpritePosition ( g_mysprite[e], g_myx[e], g_myy[e] )
g_myx[e] = g_myx[e] - 0.05
--g_myangle[e] = g_myangle[e] + 0.1
--SetSpriteAngle( g_mysprite[e], g_myangle[e] )
--SetSpriteColor ( g_mysprite[e], math.random(0,255), math.random(0,255), math.random(0,255), 255 )
end
if GetTimer(e) > 10000 and g_mysprite[e] ~= 0 then
-- Destroy(e)
DeleteSprite ( g_mysprite[e] )
-- SendMessageF("unfreezeai",0)
-- SendMessageF("unfreezeplayer",0)
Destroy(e)
end
--SendMessageF("unfreezeai",0)
-- SendMessageF("unfreezeplayer",0)
end
Also, it's hard to get the images layered in the right order.
I would really appreciate some help.
Julian - increasingly disillusioned and jaded