Forums

OverviewV-Play 1 Support › Hello

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #5897

    omescroll

    Hi there, I have a situation, kindly help me out.

    I am creating instances of an entity randomly, and would want to remove one at a time as they make contact with another wall entity object. The problem is that I have looked at all the functions to remove entities, but I can’t figure out a way to remove one at a time; ONLY when that particular one makes contact with the wall, and not remove all the others that are being created even when they are not yet used. Is there a function I don’t know about to help achieve this?

     

    By the way, I am following the sample tutorials to create something similar, and I am using “mousejoint” to drag these entities that are created at run time around. Unlike the Balloon example where U can pop using the “multitouch”, I am trying to achieve almost something similar, but this time, when it comes in contact with the wall.

     

    Thanks

    #5898

    Alex
    V-Play Team

    Hi,

    you can do something like this in your entity:

    // the collider of your entity
    BoxCollider {
      // properties and stuff...
    
      fixture.onBeginContact: {
        // determine the entityType of the collided entity
        var fixture = other;
        var body = fixture.parent;
        var component = body.parent;
        var collidedEntity = component.owningEntity;
        var collidedEntityType = collidedEntity.entityType;
        // replace "wall" with the entityType of your walls
        if(collidedEntityType === "wall") {        
          // remove the entity
          removeEntity();
        }
      }
    }

    Is this what you are looking for?

    Cheers,
    Alex

    Ps: giving the forum thread a more meaningful name helps other developers find answers if they have similar questions 😉

Viewing 2 posts - 1 through 2 (of 2 total)

RSS feed for this thread

You must be logged in to reply to this topic.

Voted #1 for:

  • Easiest to learn
  • Most time saving
  • Best support

Develop Cross-Platform Apps and Games 50% Faster!

  • Voted the best supported, most time-saving and easiest to learn cross-platform development tool
  • Based on the Qt framework, with native performance and appearance on all platforms including iOS and Android
  • Offers a variety of plugins to monetize, analyze and engage users
FREE!
create apps
create games
cross platform
native performance
3rd party services
game network
multiplayer
level editor
easiest to learn
biggest time saving
best support