How to Create a Different Actor within a Tile Of Another Actor

darkcael

  • Posts: 5
Hello! So I want to find out what box I would use to set the position of a new actor being drawn next to, above, or below the tile of another particular actor. Essentially, I am pressing down a button, and when the button is pressed I want a different actor to appear in the tile next to it. Is this possible? I am also using 16x16 tiles if that helps.

« Last Edit: November 02, 2018, 09:15:17 am by darkcael »

merrak

  • *
  • Posts: 2235
You can make a behavior to attach to your button. When it is pushed, compute the tile row, column the button resides in.  The Scenes > World palette has the block you can use to do this: Get column/row of ## in scene. Get the column/row of the x/y position of self.

Once you compute the row,column position, add one to the column to get the tile position to the right. Then create actor at x: (column * tile width) y: (row * tile height)


darkcael

  • Posts: 5
You can make a behavior to attach to your button. When it is pushed, compute the tile row, column the button resides in.  The Scenes > World palette has the block you can use to do this: Get column/row of ## in scene. Get the column/row of the x/y position of self.

Once you compute the row,column position, add one to the column to get the tile position to the right. Then create actor at x: (column * tile width) y: (row * tile height)


Hey, I think you have the right idea of what I want to do, but I'm pretty noob still at making games and at Stencyl, and I'm not sure what I'm doing wrong or how to set up the blocks of code. I've attached what I currently have, if you are able to help me fix it. Essentially, I have some booleans attached to the button presses, and if one button is pressed that boolean turns on and the other two are turned off (I'm working with three directions right now). This one I'm trying to work with is to get a light beam on the left hand side, but nothing I'm trying is working. Nothing even appears when I press the button.

merrak

  • *
  • Posts: 2235
You have the subtraction in the wrong spot. You're subtracting 1 from the tile width. You should subtract 1 from the column.

darkcael

  • Posts: 5
You have the subtraction in the wrong spot. You're subtracting 1 from the tile width. You should subtract 1 from the column.

It still doesn't seem to make the actor show up.

dtishin

  • Posts: 15
Hi, in my game I need to create "hit" (attack) object in front of my avatar.
To do this I first created the "Direction" game attribute (in settings, or the Violet blocks in the palette) and made sure the Direction attribute changes according to input from your movement controls. You can also simply use the "Point actor" block but for some reason it didn't work for all directions so I went with the game variable. (see x-movement, y-movement screenshots),
Then in the "Hitting" event I create the "Hit" actor at the avatar's coordinates plus (or minus) the tile width depending on the avatar's current Direction. Hope that helps!