Placing Sprites (Like in minecraft but 2D)

1

Index

Attached Files

The following files have been attached to this tutorial:

.capx

Stats

3,954 visits, 6,337 views

Tools

Translations

This tutorial hasn't been translated.

License

This tutorial is licensed under CC BY 4.0. Please refer to the license text if you wish to reuse, share or remix the content contained within this tutorial.

Published on 29 Aug, 2014. Last updated 19 Feb, 2019

The Script

Now we have the layout setup, go on over to your event sheet!

To start off with, make two global variables called - grass = 1 , stone = 0 (and any others, set default selected block to 1).

Next add event: Mouse > On Left button Clicked - Add condition: System > Compare Global Variable > grass = 1 - Add action: System > Create object > Object: Grass, Layer: (your choice), X: Mouse.X, Y: Mouse.Y.

Add event: Mouse > On Left button Clicked - Add condition: System > Compare Global Variable > stone = 1 - Add action: System > Create object > Object: Stone, Layer: (your choice), X: Mouse.X, Y: Mouse.Y.

Add event: Keyboard > On Key Pressed > 1 - Add action: System > Set Value > grass = 1 - Add Sub-Event: System > Compare Variable > stone = 1 - Add Action: System > Set Value > stone = 0.

Add event: Keyboard > On Key Pressed > 2 - Add action: System > Set Value > stone = 1 - Add Sub-Event: System > Compare Variable > grass = 1 - Add Action: System > Set Value > grass = 0.

Add event: grass > On Destroyed - Add action: grass > spawn another object > Object: grassbreak, Layer: (your choice), Image Point: 0.

Add event: stone > On Destroyed - Add action: stone > spawn another object > Object: stonebreak, Layer: (your choice), Image Point: 0.

Add event: Mouse > On Object Clicked > Mouse Button: Right, Click Type: Clicked, Object: grass - Add action: grass > Destroy.

Add event: Mouse > On Object Clicked > Mouse Button: Right, Click Type: Clicked, Object: stone- Add action: stone > Destroy.

Add event: grass > Is Overlapping Another Object > stone - Add action: grass > Destroy.

Add event: stone > Is Overlapping Another Object > grass - Add action: stone > Destroy.

Add event: grass > Is Overlapping Another Object > grass - Add action: grass > Destroy.

Add event: stone > Is Overlapping Another Object > stone - Add action: stone > Destroy.

END OF SCRIPT

End Result

Thanks for Reading!

Please let me know what you thought!

.CAPX
  • 0 Comments

Want to leave a comment? Login or Register an account!