JohnSundell / ImagineEngine

A project to create a blazingly fast Swift game engine that is a joy to use 🚀
Other
1.82k stars 105 forks source link

Document how Imagine Engine can be used in Swift Playgrounds on iPad #20

Open Schlumpfpapa opened 6 years ago

Schlumpfpapa commented 6 years ago

Would be great if ImagineEngine could be used in iPad Playgrounds.

As a first step I tried to put the folders „API“, „Internal“ and „UIKIt“ in xCode into an iOS Playground's „Sources“ Folder. Unfortunately xCode is stuck on „Compiling ImageEngineTest“ for over an hour now.

Can this be achieved somehow? Having ImagineEngine on iOS Playgrounds App would be huge!

Thanks and keep up the good work!

JohnSundell commented 6 years ago

Hi @Schlumpfpapa 👋

I agree, that would be amazing! I don't know if it's yet possible to import 3rd party frameworks in Swift Playgrounds for iPad though. I don't have an iPad myself at the moment, so I'm not able to try this out or work on this. But if anyone wants to check it out, and if we need to make any changes in the framework itself to make it happen, I'm all for it 👍

Schlumpfpapa commented 6 years ago

Hi again,

Using a precompiled framework in an iPad Playground is not (yet?) possible as far as I know. What is possible though, is putting a buch of source files into the „sources“ directory of a Playground. These files are getting precompiled and you can use them from the main playground file like any other code which is included there. This can be tested with xCode Playgrounds on a Mac too. Unfortunately I was not able to get it running by simple adding the three folders („API“, „Internal“ and „UIKIt“) into the „sources“ directory, but I might have done something wrong.

Schlumpfpapa commented 6 years ago

OK, actually it already does work. All you have to do is put all the files from „API“, „Internal“ and „UIKIt“ into the „sources“ folder except the files with names ending in -macOS.

Perhaps it would be a good idea to move those files in the project to a different location to simplify the process for iPad users.

You also have to put the resources folder from the Tutorial Playground into the iOS Playground.

The first few lines from the tutorial running on an iPad: img_45561a0a851c-1

JohnSundell commented 6 years ago

That is AWESOME 🚀 My desire to buy an iPad just got multiplied by 1000 😅

OK to close this now then?

Schlumpfpapa commented 6 years ago

Sure. Perhaps it would be a good idea to write some hints into the docs though and to move the offending files elsewhere perhaps, like said above.

Unfortunately I have not much practise in collaborating to a git project, otherwise I could make a pull request myself and correct the error in the tutorial code (missing import PlaygroundSupport).

JohnSundell commented 6 years ago

That's a great idea - I'll take care of it 👍 Actually the playground that the tutorial comes with already includes the PlaygroundSupport import 🙂

Thanks a lot for bringing this up and for helping me figure out how to use Imagine Engine in Swift Playgrounds on iPad - this is really exciting 🎉

Schlumpfpapa commented 6 years ago

I now was able to get the whole Tutorial Playground running on an iPad. Except for one „small“ detail: Tapping the asteroids does not trigger clicked events.

img_847c90b91e68-1

JohnSundell commented 6 years ago

Hmmm interesting. Do UIGestureRecognizers normally work in a playground's live view on iPad (because that's how the click handling is implemented)?

Schlumpfpapa commented 6 years ago

I have written an iPad Playground using SpriteKit. At least SKView.touchesBegan and SKView.touchesEnd work as expected.

JohnSundell commented 6 years ago

Since I don't have access to an iPad I'm afraid I can't be of much help debugging this 😢

insidegui commented 6 years ago

@JohnSundell This is very interesting and I do have an iPad :)

What if we had a script that generates a pre-configured playground for the developer? 🤔