S
Stephen Cena
Guest
I've been tinkering with GMP & really enjoying it. Right now, I'm trying to make card mechanics (decks, tableau, etc). My issue is with a tableau. I have an obj_Stall which has both the sprite for the tableau as well as the ds_list of the cards in the tableau. My current collision detection is done only against the obj_Stall.
When a Left Pressed is received on obj_Card:
================================
/// Pick up the card
global.active_card = self;
global.active_card.image_index = 1;
global.previous_depth = object_get_depth(self);
global.previous_x = x;
global.previous_y = y;
object_set_depth(self, active_card_depth);
================================
A Left Released event on obj_Card is:
================================
/// Drop the card
if (global.active_card != noone)
{
var dest_deck = noone;
dest_deck = instance_position(mouse_x, mouse_y, obj_Stall);
if (dest_deck != noone)
{
with (dest_deck)
{
var index = ds_list_size(deck);
global.active_card.x = x;
global.active_card.y = y + (index * deck_offset);
object_set_depth(global.active_card, index);
ds_list_add(dest_deck.deck,global.active_card);
}
} else {
global.active_card.x = global.previous_x;
global.active_card.y = global.previous_y;
object_set_depth(global.active_card, global.previous_depth);
global.active_card.image_index = 0;
}
global.active_card = noone;
}
================================
I have a obj_Controller that holds the ID for the card selected. I currently have 4 cards on screen in random locations (obj_Card->obj_D1 .. obj_Card->D4). If I click and drag the card onto the stall, it drop & displays correctly. Lets say the cards I have are (in order): 2D, 4D, AD, 3D. If I click on the visible part of the 4D I will get the 2D. My drop depth is also inconsistent. Sometimes they lay down right, other times the draw depth gets mixed up. Originally, my code for setting the depth used a negative index:
object_set_depth(global.active_card, -index);
I tried a solution where I attempted to modify the collision mask to only what was visible on screen. Couldn't get it to work when the card flipped (image_index 0 = back, image_index 1 = front).
Any help would be appreciated. Thanks!
When a Left Pressed is received on obj_Card:
================================
/// Pick up the card
global.active_card = self;
global.active_card.image_index = 1;
global.previous_depth = object_get_depth(self);
global.previous_x = x;
global.previous_y = y;
object_set_depth(self, active_card_depth);
================================
A Left Released event on obj_Card is:
================================
/// Drop the card
if (global.active_card != noone)
{
var dest_deck = noone;
dest_deck = instance_position(mouse_x, mouse_y, obj_Stall);
if (dest_deck != noone)
{
with (dest_deck)
{
var index = ds_list_size(deck);
global.active_card.x = x;
global.active_card.y = y + (index * deck_offset);
object_set_depth(global.active_card, index);
ds_list_add(dest_deck.deck,global.active_card);
}
} else {
global.active_card.x = global.previous_x;
global.active_card.y = global.previous_y;
object_set_depth(global.active_card, global.previous_depth);
global.active_card.image_index = 0;
}
global.active_card = noone;
}
================================
I have a obj_Controller that holds the ID for the card selected. I currently have 4 cards on screen in random locations (obj_Card->obj_D1 .. obj_Card->D4). If I click and drag the card onto the stall, it drop & displays correctly. Lets say the cards I have are (in order): 2D, 4D, AD, 3D. If I click on the visible part of the 4D I will get the 2D. My drop depth is also inconsistent. Sometimes they lay down right, other times the draw depth gets mixed up. Originally, my code for setting the depth used a negative index:
object_set_depth(global.active_card, -index);
I tried a solution where I attempted to modify the collision mask to only what was visible on screen. Couldn't get it to work when the card flipped (image_index 0 = back, image_index 1 = front).
Any help would be appreciated. Thanks!
Attachments
-
75.1 KB Views: 8