Remember me
You are here: HomeForumCyberix3D ForumGeneral DiscussionLightning effect attempt (help)
Welcome, Guest
Username: Password: Remember me

TOPIC: Collision '2D models'

Collision '2D models' 6 years 10 months ago #976

  • ViraX
  • ViraX's Avatar
  • OFFLINE
  • Expert Boarder
  • Posts: 148
  • Thank you received: 110
Hi,

Now we can make small 2D basic games on Cyberix3D. :woohoo:

As you already know it is possible to manipulate the position of the '2D Models', whether for a 'Set' or 'Increment'
- how to simulate a collision ? :angry:

Let's take the '2D rectangle' ... (the technic also works with the '2D Image',
For the '2D label' it's different, but possible to manipulate them graphically, I might make an example on it ... :P )

Here is a small code, which simulates a square collision ray, if another '2D rectangle' hit him, then you can interact


The example is very simple, it is up to you to improve the system of collision for a better reliability

<GameMaker3D original="1">
  <Rectangle name="sprite1" x="50" y="50" rectWidth="50" rectHeight="50" color="0x33cc"/>
  <Rectangle name="sprite2" x="50" y="250" rectWidth="50" rectHeight="50" isCollapse="0" color="0x990000">
    <Loop>
      <If var="x" ls="sprite1.x+50">
        <If var="x" gt="sprite1.x-1">
          <If var="y" ls="sprite1.y+50">
            <If var="y" gt="sprite1.y-1">
              <Remove/>
            </If>
          </If>
        </If>
      </If>
      <Increment var="y" value="-2"/>
    </Loop>
  </Rectangle>
</GameMaker3D>
The administrator has disabled public write access.
The following user(s) said Thank You: cyberix3d
Time to create page: 0.079 seconds