Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Newcomers AppGameKit Corner / Checking collision with Sprites made through an Array

Author
Message
Khadin
9
Years of Service
User Offline
Joined: 13th Feb 2015
Location: Nottingham
Posted: 26th Apr 2015 23:58 Edited at: 27th Apr 2015 02:06
Hi all.

Having issues with jumping. Currently using the command:

When i press the Up arrow sprite, the sprite moves up, then when i let go, it drops back down. Now, i want the sprite to JUMP, not FLY. I.e. when i press the up arrow, regardless of how many times i press it, it won't jump again until it hits the floor. Now, i've read the following post:

http://forum.thegamecreators.com/?m=forum_view&t=212989&b=41

And a moderator suggested doing the following:

You could check for collision below the players usual Y position. Like, make a floor from sprites with collision enabled, add platforms too of course, and get your collision working with that, even if there is no working jump function. Ideally, you'd be able to start the player on top of a platform, and make sure they can walk left and right and drop down to the floor.

Now, i have a sprite, let's call it spriteA, which gives a 1 when SpriteB is ontop of it, so far so good. But i made an array to copy the block multiply times and lay it, via:



What is the new sprite called? GetSpriteCollision(spritA, ???) I've tried everything lol

Khadin
baxslash
Valued Member
Bronze Codemaster
17
Years of Service
User Offline
Joined: 26th Dec 2006
Location: Duffield
Posted: 27th Apr 2015 09:47 Edited at: 27th Apr 2015 09:47
You need to drop the sprite ID into your array:

Then you can check for collisions by looping through the array:


Also I wouldn't load the image every time for every sprite. I would load the image near the start of the code, otherwise AppGameKit might load the same image 100s of times and crash your device.

Using AppGameKit V2 Tier 1
Khadin
9
Years of Service
User Offline
Joined: 13th Feb 2015
Location: Nottingham
Posted: 27th Apr 2015 21:27
Oki Baxslash, i think i understand Thank you

Khadin
Khadin
9
Years of Service
User Offline
Joined: 13th Feb 2015
Location: Nottingham
Posted: 1st May 2015 17:39
Still can't get this to work. Starting to get frustrated with AppGameKit Tbh. I wish there were more tutorials out there.

Khadin
baxslash
Valued Member
Bronze Codemaster
17
Years of Service
User Offline
Joined: 26th Dec 2006
Location: Duffield
Posted: 3rd May 2015 10:48
Have you seen these: http://www.appgamekit.com/code-snippets.php

Using AppGameKit V2 Tier 1

Login to post a reply

Server time is: 2024-11-23 10:29:15
Your offset time is: 2024-11-23 10:29:15