This is the source code from my Sprite Plugin Demo, this is uncompleted but I was planing to do more to it, it works for the basic sprite movement this.
PasteBin
Demo ********* Download
Please remember to make sure your AV is up to date and enabled before downloading any files off the internet, I have checked this file with Avast but you should always check files before running them.
PHP Code:
Sprite = {};
function Sprite.Int()
wait = false;
debug = true;
Up = 0;
Down = 0;
Left = 0;
Right = 0;
_WinHandle = Application.GetWndHandle();
end
function Sprite.Easy(s_image, t_images, n_width, n_height, n_speed, m_l, m_u, m_r, m_d)
--Application.SetPageScript("Page1", "On Show", "Sprite.Int();");
OnKeyScript =[[-- Genareated by Easy function
if e_Key == _Left or e_Key == _UP or e_Key == _Right or e_Key == _Down then
Sprite.Move(]]..tostring(s_image)..[[, e_Key, ]]..n_width..[[, ]]..n_height..[[, ]]..n_speed..[[, ]]..m_l..[[, ]]..m_u..[[, ]]..m_r..[[, ]]..m_d..[[);
Sprite.Switch(]]..tostring(s_image)..[[, e_Key, ]]..t_images..[[);
end]];
--Application.SetPageScript("Page1", "On Key", OnKeyScript);
Dialog.Message("", OnKeyScript);
end
function Sprite.Move(s_image, m_drc, n_width, n_height, n_speed, m_l, m_u, m_r, m_d)
WindSize = Window.GetSize(Application.GetWndHandle());
G_B = {Y = 0, X = 0, W = n_width, H = n_height};
PCU_B = {Y = Image.GetPos(s_image).Y,X = Image.GetPos(s_image).X, W = Image.GetSize(s_image).Width, H=Image.GetSize(s_image).Height};
if n_speed == nil or n_speed == '' then
n_speed = 1;
end
if m_l == nil or m_l == '' then
m_l = 0;
end
if m_u == nil or m_u == '' then
m_u = 0;
end
if m_r == nil or m_r == '' then
m_r = 0;
end
if m_d == nil or m_d == '' then
m_d = 0;
end
if m_drc == _UP then
ImCon = PCU_B.Y - m_u;
if ImCon <= G_B.Y then
Y_Action = PCU_B.Y;
X_Action = PCU_B.X;
else
Y_Action = PCU_B.Y-n_speed;
X_Action = PCU_B.X;
end
end
if m_drc == _Down then
ImCon = PCU_B.Y + PCU_B.H - m_d;
if ImCon >= n_height then
Y_Action = PCU_B.Y;
X_Action = PCU_B.X;
else
Y_Action = PCU_B.Y+n_speed;
X_Action = PCU_B.X;
end
end
if m_drc == _Left then
ImCon = 0 - m_l;
if PCU_B.X <= ImCon then
Y_Action = PCU_B.Y;
X_Action = PCU_B.X;
else
Y_Action = PCU_B.Y;
X_Action = PCU_B.X-n_speed;
end
end
if m_drc == _Right then
ImCon = PCU_B.X + PCU_B.W - m_r;
if ImCon >= n_width then
Y_Action = PCU_B.Y;
X_Action = PCU_B.X;
else
Y_Action = PCU_B.Y;
X_Action = PCU_B.X+n_speed;
end
end
if wait ~= true then
Image.SetPos(s_image, X_Action, Y_Action);
end
end
function Sprite.Switch(s_image, m_drc, t_images)
if type(t_images) ~= 'table' then
Dialog.Message('Eror', 'Argument 3 must be of a table type.');
return 'Argument 3 must be of a table type.';
else
if m_drc == _UP then
Down = 0;
Left = 0;
Right = 0;
if Up == 0 or Up == 6 then
Image.Load(s_image, t_images.UP.One);
Up = Up+1;
elseif Up == 1 or Up == 2 or Up == 4 or Up == 5 or Up == 7 or Up == 8 or Up == 10 or Up == 11 then
Up = Up+1;
elseif Up == 3 then
Image.Load(s_image, t_images.UP.Two);
Up = Up+1;
elseif Up == 9 then
Image.Load(s_image, t_images.UP.Three);
Up = Up+1;
elseif Up == 12 then
Up = 0;
end
end
if m_drc == _Down then
Up = 0;
Left = 0;
Right = 0;
if Down == 0 or Down == 6 then
Image.Load(s_image, t_images.Down.One);
Down = Down+1;
elseif Down == 1 or Down == 2 or Down == 4 or Down == 5 or Down == 7 or Down == 8 or Down == 10 or Down == 11 then
Down = Down+1;
elseif Down == 3 then
Image.Load(s_image, t_images.Down.Two);
Down = Down+1;
elseif Down == 9 then
Image.Load(s_image, t_images.Down.Three);
Down = Down+1;
elseif Down == 12 then
Down = 0;
end
end
if m_drc == _Left then
Up = 0;
Down = 0;
Right = 0;
if Left == 0 or Left == 6 then
Image.Load(s_image, t_images.Left.One);
Left = Left+1;
elseif Left == 1 or Left == 2 or Left == 4 or Left == 5 or Left == 7 or Left == 8 or Left == 10 or Left == 11 then
Left = Left+1;
elseif Left == 3 then
Image.Load(s_image, t_images.Left.Two);
Left = Left+1;
elseif Left == 9 then
Image.Load(s_image, t_images.Left.Three);
Left = Left+1;
elseif Left == 12 then
Left = 0;
end
end
if m_drc == _Right then
Up = 0;
Down = 0;
Left = 0;
if Right == 0 or Right == 6 then
Image.Load(s_image, t_images.Right.One);
Right = Right+1;
elseif Right == 1 or Right == 2 or Right == 4 or Right == 5 or Right == 7 or Right == 8 or Right == 10 or Right == 11 then
Right = Right+1;
elseif Right == 3 then
Image.Load(s_image, t_images.Right.Two);
Right = Right+1;
elseif Right == 9 then
Image.Load(s_image, t_images.Right.Three);
Right = Right+1;
elseif Right == 12 then
Right = 0;
end
end
end
end
Demo ********* Download
Please remember to make sure your AV is up to date and enabled before downloading any files off the internet, I have checked this file with Avast but you should always check files before running them.