help with Sticker Knight

Trying to learn…

seeing as my last post was never approved, ill keep it short.

I’m sure there are several ways, but, how would one add a second enemy.lua for example enemyTwo.lua and be able to IMG tile it in the Tiled program as well as incorporate it into the same sprite sheet that it provided with that game code. 

TY

Let me see if I can help…

  1. “Blobs” in blob.lua is a secondary enemy class. I would start from that one and try to make something simple, like a bat. Just copy the file, call it bat.lua.

  2. Now let the map extensions know it’s there in these lines in game.lua (Line 55)

    – Find our enemies and other items map:extend( “blob”, “enemy”, “exit”, “coin”, “spikes”, “bat” ) – right here!!!

  3. Now just add put a bat.png file in the folder with the rest of the graphics, add it to the tileset, and drop it in with the type “bat.”

If you don’t change anything else you should get a bat that acts like the blob. Now experiment with giving the bat properties like instant.gravityScale = 0 to make it fly, and add some vertical motion.

If that sounds too complicated. Play with some of the simpler classes like spikes or coins to see how they work.

Thanks for that Michael! I had some issues getting the bat to show. After trying your steps on a fresh copy of the game i was able to get the bat to show up! He is moving around in a similar pattern as the blob. One thing, its not doing any damage to the hero and it can not be "killed by jumping on it, it acts like a block i can stand on that moves lol? Any idea why everything else would work but that wouldn’t? Thanks again for your time Michael, your not only brilliant but very helpful and giving of your time and I very much appreciate it! 

Bump!!

Check out the hero.lua file and look at the collision() function…

 function instance:collision( event ) local phase = event.phase local other = event.other local y1, y2 = self.y + 50, other.y - ( other.type == "enemy" and 25 or other.height/2 ) local vx, vy = self:getLinearVelocity() if phase == "began" then if not self.isDead and ( other.type == "blob" or other.type == "enemy" ) then if y1 \< y2 then -- Hopped on top of an enemy other:die() elseif not other.isDead then -- They attacked us self:hurt() end elseif self.jumping and vy \> 0 and not self.isDead then -- Landed after jumping self.jumping = false if not ( left == 0 and right == 0 ) and not instance.jumping then instance:setSequence( "walk" ) instance:play() else self:setSequence( "idle" ) end end end end

Line 108 has the types that cause damage. Just add your type in…

Thanks so much for that intel, I must be simple because i was sure i had checked in there! Thanks again Michael! It worked perfectly! Thanks so much for your time! 

Let me see if I can help…

  1. “Blobs” in blob.lua is a secondary enemy class. I would start from that one and try to make something simple, like a bat. Just copy the file, call it bat.lua.

  2. Now let the map extensions know it’s there in these lines in game.lua (Line 55)

    – Find our enemies and other items map:extend( “blob”, “enemy”, “exit”, “coin”, “spikes”, “bat” ) – right here!!!

  3. Now just add put a bat.png file in the folder with the rest of the graphics, add it to the tileset, and drop it in with the type “bat.”

If you don’t change anything else you should get a bat that acts like the blob. Now experiment with giving the bat properties like instant.gravityScale = 0 to make it fly, and add some vertical motion.

If that sounds too complicated. Play with some of the simpler classes like spikes or coins to see how they work.

Thanks for that Michael! I had some issues getting the bat to show. After trying your steps on a fresh copy of the game i was able to get the bat to show up! He is moving around in a similar pattern as the blob. One thing, its not doing any damage to the hero and it can not be "killed by jumping on it, it acts like a block i can stand on that moves lol? Any idea why everything else would work but that wouldn’t? Thanks again for your time Michael, your not only brilliant but very helpful and giving of your time and I very much appreciate it! 

Bump!!

Check out the hero.lua file and look at the collision() function…

 function instance:collision( event ) local phase = event.phase local other = event.other local y1, y2 = self.y + 50, other.y - ( other.type == "enemy" and 25 or other.height/2 ) local vx, vy = self:getLinearVelocity() if phase == "began" then if not self.isDead and ( other.type == "blob" or other.type == "enemy" ) then if y1 \< y2 then -- Hopped on top of an enemy other:die() elseif not other.isDead then -- They attacked us self:hurt() end elseif self.jumping and vy \> 0 and not self.isDead then -- Landed after jumping self.jumping = false if not ( left == 0 and right == 0 ) and not instance.jumping then instance:setSequence( "walk" ) instance:play() else self:setSequence( "idle" ) end end end end

Line 108 has the types that cause damage. Just add your type in…

Thanks so much for that intel, I must be simple because i was sure i had checked in there! Thanks again Michael! It worked perfectly! Thanks so much for your time!