Selaa lähdekoodia

Improved instructions

Björn Ritzl 3 vuotta sitten
vanhempi
commit
82b1060690

+ 11 - 1
examples/factory/bullets/bullets.md

@@ -4,6 +4,16 @@ brief: This example shows how to dynamically spawn bullet game objects using a f
 scripts: player.script
 ---
 
-This example shows how to dynamically spawn bullet game objects using a factory component and how to also move and delete the bullets.
+This example shows how to dynamically spawn bullet game objects using a factory component and how to also move and delete the bullets. The setup consists of two game objects; one for the player and one for the bullet that is spawned using a factory component.
 
 Combine this example with some of the examples from the movement and physics categories to create a shoot 'em up game!
+
+player
+: The red ship at the bottom. Contains:
+  - A *Sprite* component with the spaceship image.
+  - A *Factory* component to spawn bullet game objects
+  - A script to handle spawning of bullets.
+
+bullet
+: The bullet fired by the player. Contains:
+  - A *Sprite* component with a bullet image.

+ 4 - 4
examples/factory/bullets/player.script

@@ -14,13 +14,13 @@ function on_input(self, action_id, action)
 		local bullet_id = factory.create("#bulletfactory", pos)
 
 		-- animate the bullet
-		local distance = 1000					-- distance in pixels
-		local speed = 800						-- pixels per second
-		local duration = distance / speed		-- time in second to travel the full distance
+		local distance = 1000                   -- distance in pixels
+		local speed = 800                       -- pixels per second
+		local duration = distance / speed       -- time in second to travel the full distance
 		local to = pos.y + distance
 		-- start animation and delete bullet when it has reached its destination
 		go.animate(bullet_id, "position.y", go.PLAYBACK_ONCE_FORWARD, to, go.EASING_LINEAR, duration, 0, function()
 			go.delete(bullet_id)
 		end)
 	end
-end
+end

+ 4 - 4
examples/physics/knockback/player.script

@@ -14,13 +14,13 @@ function on_input(self, action_id, action)
 		local bullet_id = factory.create("#bulletfactory", pos)
 
 		-- animate the bullet
-		local distance = 1000					-- distance in pixels
-		local speed = 800						-- pixels per second
-		local duration = distance / speed		-- time in second to travel the full distance
+		local distance = 1000                   -- distance in pixels
+		local speed = 800                       -- pixels per second
+		local duration = distance / speed       -- time in second to travel the full distance
 		local to = pos.y + distance
 		-- start animation and delete bullet when it has reached its destination
 		go.animate(bullet_id, "position.y", go.PLAYBACK_ONCE_FORWARD, to, go.EASING_LINEAR, duration, 0, function()
 			go.delete(bullet_id)
 		end)
 	end
-end
+end