Last active
December 4, 2015 00:31
-
-
Save nakosung/ee76a5f41a59627f22cf to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Context.RunFile('aliases.js') | |
Context.RunFile('polyfill/unrealengine.js') | |
Context.RunFile('polyfill/timers.js') | |
function client() { | |
class MyTextRenderActor extends TextRenderActor { | |
ctor() { | |
this.AppComponent = ApplicationLifecycleComponent.CreateDefaultSubobject("Lifecycle") | |
this.AppComponent.ApplicationHasEnteredForegroundDelegate.Add(() => { | |
this.TextRender.SetText("App foreground") | |
}) | |
} | |
} | |
let MyActor_C = require('uclass')()(global, MyTextRenderActor) | |
let actor = new MyActor_C(GWorld, { X: 100, Z: 100 }, { Yaw: 180 }) | |
actor.TextRender.SetHorizontalAlignment('EHTA_Center') | |
let str = Root.ResolveAsset('anim',true) | |
let setText = (text) => actor.TextRender.SetText(text) | |
setText(Root.ResolveAsset('skel',true) + str + ' assets') | |
let urls = [ | |
"https://pbs.twimg.com/profile_images/467513283092553729/-5z384Kq_400x400.png", | |
"http://icon.gamerzcraft.com/capas/Aion_The_Tower_Of_Eternity_[691-1-2195109].png", | |
"http://megaicons.net/static/img/icons_sizes/91/1257/256/aion-9-icon.png", | |
"http://megaicons.net/static/img/icons_sizes/91/1257/256/aion-4-icon.png" | |
] | |
let PC = GetPC() | |
let t = 0 | |
let radius = 50 | |
function tick(dt) { | |
t += dt | |
PC.GetControlledPawn().SetActorLocation({ Z: Math.cos(t) * radius + 120, Y: Math.sin(t) * radius }) | |
} | |
Root.OnTick.Add(tick) | |
let textures = [] | |
urls.forEach((url) => { | |
let job = AsyncTaskDownloadImage.DownloadImage(url) | |
job.OnSuccess.Add((tex) => { textures.push(tex) }) | |
}) | |
// declare our own HUD class | |
class MyHUD extends HUD { | |
// override ReceiveDrawHUD | |
ReceiveDrawHUD() { | |
// don't forget to its super function | |
super.ReceiveDrawHUD() | |
textures.forEach((texture, i) => { | |
this.Canvas.DrawTexture(texture, { X: 100 + 210 * i, Y: 0 }, { X: 200, Y: 200 }, { X: 0, Y: 0 }, { X: 1, Y: 1 }, { R: 1, G: 1, B: 1, A: 1 }, 'BLEND_Opaque') | |
}) | |
} | |
} | |
// register new HUD class | |
let MyHUD_C = require('uclass')()(global, MyHUD); | |
// and instantiate it | |
GetPC().ClientSetHUD(MyHUD_C) | |
return function () { | |
Root.OnTick.Remove(tick) | |
actor.DestroyActor() | |
} | |
} | |
client() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment