I'm trying to make a basic Zelda clone and I'm having some trouble figuring out how implement an "attack" action using the confirm function.
I've got the player to draw a sword swipe on the appropriate adjacent tile when pressing A, but I can't seem to get a sprite to disappear after being "attacked." Here's the script for the sprite:
on destroy do
positionX = event.x
positionY = event.y
position = name positionX,positionY
if position=="slashLeft" then
swap "white"
end
end
When performing the attack action, the player does "emit destroy" if that helps.
I took a look at your code and I noted a few issues. First, what I did was start logging to make sure things are executing. For instance,
on destroy do
positionX = event.x
positionY = event.y
position = name positionX,positionY
log "destroying {positionX}, {positionY}"
and so on. Just a strategy to keep in mind for the future.
The first issue I found was:
emit destroy
This should be
emit "destroy"
Events/functions still have to be passed as strings of their names.
Second, note that emit emits to every single tile that supports that event. So in your case, hitting ANY hazard tile emits to ALL of them telling them they're destroyed.