Rectangle components in NAT
This commit is contained in:
@@ -34,6 +34,9 @@
|
|||||||
(change playgrounds)
|
(change playgrounds)
|
||||||
(File.saveContent (joinPath archiveDir "playgrounds.json") (haxe.Json.stringify playgrounds "\t")))
|
(File.saveContent (joinPath archiveDir "playgrounds.json") (haxe.Json.stringify playgrounds "\t")))
|
||||||
|
|
||||||
|
(method :String currentPlayground []
|
||||||
|
(dictGet playgrounds "default"))
|
||||||
|
|
||||||
(method addSystem [:System system]
|
(method addSystem [:System system]
|
||||||
(systems.push system)
|
(systems.push system)
|
||||||
system)
|
system)
|
||||||
|
|||||||
@@ -313,6 +313,22 @@
|
|||||||
(removeTags archive e tagsToRemove))
|
(removeTags archive e tagsToRemove))
|
||||||
entries) // TODO this includes entries that didn't have the tag in the changeset
|
entries) // TODO this includes entries that didn't have the tag in the changeset
|
||||||
|
|
||||||
|
(defCommand AddRectangle [entries (SelectedEntries 1 null)
|
||||||
|
width (Number 0 null null)
|
||||||
|
height (Number 0 null null)]
|
||||||
|
(doFor e entries
|
||||||
|
(addComponent archive e Rectangle (objectWith width height)))
|
||||||
|
entries)
|
||||||
|
|
||||||
|
(defCommand CreateRectangleEntry [p1 Position p2 Position]
|
||||||
|
[(archive.createEntry ->e
|
||||||
|
(let [x (min p1.x p2.x)
|
||||||
|
y (min p1.y p2.y)
|
||||||
|
w (- (max p1.x p2.x) x)
|
||||||
|
h (- (max p1.y p2.y) y)]
|
||||||
|
(addComponent archive e Positions [=>(archive.currentPlayground) (objectWith [z 0.0] x y)])
|
||||||
|
(addComponent archive e Rectangle (object width w height h))))])
|
||||||
|
|
||||||
(defCommand AddDLURL [e SelectedEntry url (Text null)]
|
(defCommand AddDLURL [e SelectedEntry url (Text null)]
|
||||||
[(addComponent archive e DLURL url)])
|
[(addComponent archive e DLURL url)])
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,6 @@
|
|||||||
|
package nat.components;
|
||||||
|
|
||||||
|
typedef Rectangle = {
|
||||||
|
width:Float,
|
||||||
|
height:Float
|
||||||
|
}
|
||||||
@@ -27,6 +27,12 @@
|
|||||||
(otherwise
|
(otherwise
|
||||||
(.onComplete (BitmapData.loadFromFile pinnedImage)
|
(.onComplete (BitmapData.loadFromFile pinnedImage)
|
||||||
->bitmapData (loadGraphic bitmapData))))))
|
->bitmapData (loadGraphic bitmapData))))))
|
||||||
|
((hasComponent e Rectangle)
|
||||||
|
(let [rect (readComponent e Rectangle)
|
||||||
|
w (Std.int rect.width)
|
||||||
|
h (Std.int rect.height)]
|
||||||
|
(makeGraphic w h FlxColor.TRANSPARENT)
|
||||||
|
(FlxSpriteUtil.drawRect this 0 0 w h FlxColor.TRANSPARENT (object color FlxColor.WHITE))))
|
||||||
((hasComponent e Circle)
|
((hasComponent e Circle)
|
||||||
(set isCircle true)
|
(set isCircle true)
|
||||||
(let [c (readComponent e Circle)
|
(let [c (readComponent e Circle)
|
||||||
|
|||||||
@@ -11,7 +11,7 @@
|
|||||||
(super
|
(super
|
||||||
playState
|
playState
|
||||||
->[archive e]
|
->[archive e]
|
||||||
?(or (hasComponent e Name) (hasComponent e Circle))
|
?(or (hasComponent e Name) (hasComponent e Circle) (hasComponent e Rectangle))
|
||||||
->[archive e pos &opt ui]
|
->[archive e pos &opt ui]
|
||||||
(unless (sprites.exists e.id)
|
(unless (sprites.exists e.id)
|
||||||
(let [sprite (new EntrySprite this _playgroundKey pos archive e controller)]
|
(let [sprite (new EntrySprite this _playgroundKey pos archive e controller)]
|
||||||
|
|||||||
Reference in New Issue
Block a user