adding space and tryout with lines

This commit is contained in:
Torsten Ruger 2015-07-09 16:34:02 +03:00
parent ab48f10ee8
commit 456fdc93e1
3 changed files with 37 additions and 2 deletions

View File

@ -1,6 +1,7 @@
require 'opal/pixi'
require 'native'
require "main/lib/registers_view"
require "main/lib/space_view"
class MainView
@ -15,11 +16,16 @@ class MainView
html_con = body.firstElementChild
html_con.insertBefore renderer.view , html_con.lastElementChild
@container.add_child RegisterView.new(height - 150)
registers = RegisterView.new(height - 150)
@container.add_child registers
space = SpaceView.new
@container.add_child space
animate = Proc.new do
`requestAnimationFrame(animate)`
renderer.render @container
registers.update
space.update
renderer.render @container
end
animate.call

View File

@ -14,5 +14,8 @@ class RegisterView < PIXI::Container
@registers[name] = reg
self.add_child reg
end
def update
end
end
end

View File

@ -0,0 +1,26 @@
class SpaceView < PIXI::Graphics
def initialize objects
super()
@objects = objects
@pos1 = PIXI::Point.new 100 , 100
@pos2 = PIXI::Point.new 200 , 200
@text1 = PIXI::Text.new "ONE"
@text2 = PIXI::Text.new "TWO"
@text1.position = @pos1
@text2.position = @pos2
add_child @text1
add_child @text2
end
def update
self.clear
self.lineStyle(4, 0xffd900, 2)
self.moveTo(@pos1.x , @pos1.y )
self.lineTo( @pos2.x , @pos2.y)
@pos1.x += 1
end
end