From 150944ee9e41df2ae5ee25c7845c3f5b2bd74af0 Mon Sep 17 00:00:00 2001 From: chai Date: Fri, 7 Dec 2018 11:22:59 +0800 Subject: =?UTF-8?q?*=E7=A7=81=E6=9C=89=E5=8C=96shared=20object=20template?= =?UTF-8?q?=20retain=E5=92=8Crelease?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- bin/game/main.lua | 28 ++++++++++++++++++++++++++-- bin/game/particle.png | Bin 0 -> 1821 bytes bin/jin.exe | Bin 540672 -> 554496 bytes 3 files changed, 26 insertions(+), 2 deletions(-) create mode 100644 bin/game/particle.png (limited to 'bin') diff --git a/bin/game/main.lua b/bin/game/main.lua index 8ff5e68..6851c45 100644 --- a/bin/game/main.lua +++ b/bin/game/main.lua @@ -53,17 +53,39 @@ local bitmap = nil local sprs = {} local animator = nil local spr = nil +local particle_sprite = nil +local ps = nil local function createAnimation(path, count, r, c, w, h, loop, speed) local tex = jin.graphics.newTexture(path) local ssheet = jin.graphics.newSpriteSheet(tex) local sprs = ssheet:newSprites(count, r, c, w, h, 96, 168) return jin.graphics.newAnimation(sprs, loop, speed) end - +local Pi = 3.1415 +local tex = nil function jin.core.onLoad() -- bitmap = jin.graphics.newBitmap(200, 200, function(w, h, x, y) -- return {255*math.sin(x/w),255 - 255,255*math.cos(y/w),255} -- end) + tex = jin.graphics.newTexture("particle.png") + particle_sprite = jin.graphics.newSprite(tex, jin.graphics.SpriteOrigin.MIDDLECENTER) + ps = jin.graphics.newParticleSystem() + + ps:setEmitRate(0.02); + ps:setEmitForce(80, 120); + ps:setEmitPosition({50, 50}); + ps:setEmitDirection(-Pi / 10 - Pi / 2, Pi / 10 - Pi / 2); + ps:setParticleLinearAccelaration({0, 10}); + ps:setParticleSpritesMode(jin.graphics.SpriteMode.SINGLE); + ps:setParticleColor({255, 30, 0, 255}); + ps:addParticleTransparencyPoint(1, 0); + ps:addParticleTransparencyPoint(0, 0.5); + ps:enableParticleBlendAdditive(true); + ps:setParticleLife(0.5, 2); + ps:addParticleScalePoint(3, 0); + ps:addParticleScalePoint(0, 1); + ps:addParticleSprite(particle_sprite) + shader_program = jin.graphics.newShader(shader) shader_program2 = jin.graphics.newShader(shader2) local animation = createAnimation("anim2.png", 27, 3, 10, 200, 200, true, 50) @@ -97,11 +119,12 @@ function jin.core.onEvent(e) end end -function jin.core.onUpdate() +function jin.core.onUpdate(dt) tb.x = t t = t + jin.time.getDelta() animator:update(jin.time.getDelta()) timer:update(jin.time.getDelta()) + ps:update(dt) end function jin.core.onDraw() @@ -113,6 +136,7 @@ function jin.core.onDraw() --jin.graphics.draw(sprs[2], 150, 150, 1, 1, 0) local x, y = jin.mouse.getPosition() animator:render(x, y, 1, 1, 0) + ps:render() --jin.graphics.print(#sprs, 10, 10) jin.graphics.draw(spr, 100, 200, 1, 1, 0) --jin.graphics.useShader(shader_program2) diff --git a/bin/game/particle.png b/bin/game/particle.png new file mode 100644 index 0000000..632fcc1 Binary files /dev/null and b/bin/game/particle.png differ diff --git a/bin/jin.exe b/bin/jin.exe index 4e260c9..c74c8b7 100644 Binary files a/bin/jin.exe and b/bin/jin.exe differ -- cgit v1.1-26-g67d0