It looks like you're new here. If you want to get involved, click one of these buttons!
Hi, today i updated my simple screen carrier library. Now it can do many cool things.
This library contains two classes:
First is "struct_touch" that represents information about touch-event in non constant form, also it has some service functions for main class("screen").
Second class is main class of the library. It is named "screen".
It represents part of the main screen as single frame with it's own drawing and touching space(or coordinate system, named it as you wish).
Also it is a container that automatically scrolls draw- and touch-event thru all of it members(object that contains in this container).
As part of main screen it automatically track WIDTH and HEIGHT global values and device orientation and corrects self width, height and position on the screen.
Width, height and position of frame can be in proportion with main screen WIDTH and HEIGHT and it can be precise value in pixels.
If it is proportions SSC("screen" class member) will automatically detect changes in WIDTH and HEIGHT and correct self width, height and position.
--=====================TOUCHFINDER===================
touchfinder = class()
function touchfinder:init()
self.pos = nil
self.state = nil
self.color = color(128)
end
function touchfinder:draw()
if self.pos == nil or self.state == nil then
return
end
if self.state == BEGAN then
fill(255)
elseif self.state == ENDED then
fill(0)
else
fill(self.color)
end
ellipse(self.pos.x, self.pos.y, 100)
end
function touchfinder:touched(touch)
self.pos = vec2(touch.x, touch.y)
self.state = touch.state
end
--=====================MAINFUNC===================
function setup()
spriteMode(CORNER)
--global value that can be overloaded
lol = 1
scr1 = screen(0.5, nil, nil, {lol = 2})
scr2 = screen(0.5, nil, vec2(0.5, 0), {lol=3})
scr1.background = color(255,0,0,10)
scr2.background = color(0,255,0,10)
tf1 = touchfinder()
tf2 = touchfinder()
tf1.color = color(255,255,0)
tf2.color = color(0,0,255)
scr1:push(tf1)
scr2:push(tf2)
--[[
--print is very slow function
--uncomment this section to see globals swaping
scr1.CallFirst = function() print("First: ", lol) return true end
scr2.CallFirst = function() print("Second: ", lol) return true end
]]
end
function draw()
--[[
--uncomment this section to see globals swaping
print("Global: ", lol)
]]
scr1:draw()
scr2:draw()
end
function touched(touch)
scr1:touched(touch)
scr2:touched(touch)
end
By Pastebin: SSC.lib V1
or by code: in first comment
Thanks for reading your comments and suggestions are welcome
Comments
Can you maybe show a little video so we can see what it does?
@Ignatz
Sorry, but i can't, and i have couple of reasons why:
1. Codea not supported orientation changing while video capturing, every time when i try to capture video and changes orientation of my device video capture stops without saving.
2. This library is system-style. It helps you to do your projects quickly without meeting troubles with container-class creation while your project in coding phase and orientation changing while your project is running.
I can provide simple example of usage(as i did), but i better explain here main idea of this lib:
Usage must be simple:
1. Create your container("screen" class element)
2. Push your objects in it
3. Don't worry, be happy:)
I'm still not sure what it does!
@Ignatz
I want to share this lib with other developers because i use something like container-class, and screen divider(class that captures touch-events in some part of the screen) class for all my big projects. But this lib includes all of it in one class with minimum amount of code and some cool build-in features(as local globals overload and pre-post-event user-defined function calls).
I am sure that i will use this lib in my future projects.