[SOLVED]: Drag And Drop (Last Collided Actor returns Null?) Help

Firiyuu77

  • Posts: 21
Hello, I'm trying to make a drag and drop game.

Where, the user tries to  drag a card to a certain point at the screen, so in order to do this, I wanted to modify the drag and drop behavior for a bit.

Here is my poor attempt: http://prntscr.com/ig7mmm


If Animation for Actortype1 == Animation for Actortype2
-Do something/Discard both or push them wherever....

What can I do so I can access both of the animations in their ActorTypes? I know they're not working because I'm getting the frames instead of the animations.


« Last Edit: February 19, 2018, 09:56:29 am by Firiyuu77 »

merrak

  • *
  • Posts: 1962
I'm not sure I understand the question. There's the 'animation for XX' blocks in the actor -> draw palette. Is that what you're looking for?

Firiyuu77

  • Posts: 21
Hello,

First of all, Thanks! I was able to come up with this:(Please look at the screenshot, I updated the Drawing part) I forgot that the animation switching can be found there, but unfortunately it doesn't work the way I want it to. It has these errors: http://prntscr.com/igaxl6


Here's the part that I added: http://prntscr.com/igaypg

Here's my Actor Types that I wanted to manipulate, in other words, I want a drag and drop game, where if I collide ActorType(Animation0) with ActorType1(Animation0) ... ActorType1(Animation0) gets push 180 degrees.

ActorType: http://prntscr.com/igaz2g
ActorType1: http://prntscr.com/igaz5o

« Last Edit: February 17, 2018, 10:11:58 pm by Firiyuu77 »

squeeb

  • Posts: 1308
A null pointer error is when you reference something that isnt there...  maybe the last collided actor part...also, its pushing in a drawing event :)

Firiyuu77

  • Posts: 21
Thanks, but yes it's definitely pointing on null, but I don't know why, is the problem.  I mean let's say

ActorType                        ActorType1
0                                               0
1                                              1
2                                              2
3                                              3
4                                              4
5                                              5
6                                              6


My structure says that:

If Animation in Self(The one im dragging - ActorType1) is equal to the animation it collides in ActorType
-Push ActorType  it 180 degrees in Pi force.

I think nothing should happen if objects from the same line collides, because they're different.
I don't know why it's pointing to null. Gosh haha, this is indeed challenging.

If you have a drag and drop game how would you approach it?

http://prntscr.com/igbghq - Let's say it looks like this, and I want to match it to the other, and if they match it would do something to the left column?

Sorry for the trouble, I'm a developer myself, but have only touched stencyl for a couple of days. I wanted to do it with Godot or anywhere I could hardcode, but my kids' teacher wants them to use scratch or stencyl, I feel so old right now. I thought it was easy, but definitely this is not my forte.




« Last Edit: February 17, 2018, 11:47:49 pm by Firiyuu77 »

Firiyuu77

  • Posts: 21
I solved the error by making it a String, For both of them instead of Numbers, well that was confusing...  instead of pushing to check if its working I just made it to make a sound. But it's not working.

« Last Edit: February 18, 2018, 04:02:34 am by Firiyuu77 »

Firiyuu77

  • Posts: 21
Why does "Last Collided" Returns a Null?

Error Message:
http://prntscr.com/igdaaz


It's supposed to return something right? Like when the object I'm dragging and dropping collides into something? Can someone explain to me how Stencyl deals with it? I don't get why I'm getting a null here.


« Last Edit: February 18, 2018, 06:47:58 am by Firiyuu77 »

Firiyuu77

  • Posts: 21
Finally I made it work by using the collision(which I didn't know it was just there until I watched a certain video) however the sound is ringing for every partnering. I think I have already set that:

if animation for self == animation to the colided
RING!!!

I was expecting 0 to 0 would ring and 0 to 1 wouldn't.  Anyone knows what I have done wrong? Take a look at the collision part


merrak

  • *
  • Posts: 1962
"Last Collided" is likely returning null because nothing has collided with the actor in the first few frames. The way drawing events work is that all code in them is executed roughly 60 times per second--every time the screen needs to be painted.

I think the block was designed to be used with the collision events. Those wouldn't trigger unless something collided with the actor. There is a block in the attributes -> functions palette that will let you check if an actor has a value (Stencyl's wording for "null").

In your last screenshot, I'd use the '1st actor' and '2nd actor' blocks to refer to 'ans' and 'testes'.

If it's still not working, can you upload what you have so far to the Stencyl Arcade? It'd be easier to see what is going wrong that way.

Sorry for the trouble, I'm a developer myself, but have only touched stencyl for a couple of days. I wanted to do it with Godot or anywhere I could hardcode, but my kids' teacher wants them to use scratch or stencyl, I feel so old right now. I thought it was easy, but definitely this is not my forte.

You can use 'code mode' to write Haxe code... you can even use your own editor. I use this approach with 'mooedit' for pretty much anything other than simple scripts these days. That might be more familiar for you if you're used to text. However, if this is for your kids' assignment then they're probably expected to use blocks.

A lot of the default behaviors have complex code, because they were designed to be highly configurable.

Firiyuu77

  • Posts: 21
I figured it out! Thank you very much to the answers!