アンドロイドアプリケーション内でProcessingスケッチを実行しようとしています。 このスケッチでは、raw
ディレクトリにあるSVG
ファイルにアクセスする必要があります。 そのファイルにアクセスする方法がわかりません。たとえファイルがディレクトリ "data"にあっても、処理の仕組みと全く同じですが、全く機能しません。このサンプルコードを確認してください:Android Studioを使用して処理中のファイルにアクセスする方法
import processing.core.PApplet;
import processing.core.PShape;
import processing.core.PVector;
public class Menu extends PApplet {
/**************************************************/
//icon:
PShape icon;
/**************************************************/
public void settings()
{
size(displayHeight, displayHeight);
}
/**************************************************/
public void setup()
{
icon = loadShape("menu.svg"); //here is where an error occurs;
}
/**************************************************/
public void draw()
{
background(0);
}
/**************************************************/
UPDATE
エラーメッセージを:あなたはSDカード、SQLiteのデータベースまたはsharedpreferences内の画像(またはその他のデータ)を記憶することができる
---------
beginning of crash
09-07 07:36:07.503 2939-2986/letalis.safr.com.letalis E/AndroidRuntime: FATAL EXCEPTION: Animation Thread
Process: letalis.safr.com.letalis, PID: 2939
java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.String processing.data.XML.getString(java.lang.String)' on a null object reference
at processing.core.PShapeSVG.<init>(Unknown Source)
at processing.core.PShapeSVG.<init>(Unknown Source)
at processing.core.PGraphicsAndroid2D.loadShape(Unknown Source)
at processing.core.PApplet.loadShape(Unknown Source)
at letalis.safr.com.letalis.Esquech_Menu.setup(Esquech_Menu.java:111)
at processing.core.PApplet.handleDraw(Unknown Source)
at processing.core.PSurfaceNone.callDraw(Unknown Source)
at processing.core.PSurfaceNone$AnimationThread.run(Unknown Source)
09-07 07:36:07.578 2939-2952/letalis.safr.com.letalis W/EGL_emulation: eglSurfaceAttrib not implemented
09-07 07:36:07.578 2939-2952/letalis.safr.com.letalis W/OpenGLRenderer: Failed to set EGL_SWAP_BEHAVIOR on surface 0xacb7f860, error=EGL_SUCCESS
09-07 07:36:07.592 2939-2952/letalis.safr.com.letalis E/Surface: getSlotFromBufferLocked: unknown buffer: 0xaebf1150
09-07 07:36:07.734 2939-2952/letalis.safr.com.letalis W/EGL_emulation: eglSurfaceAttrib not implemented
09-07 07:36:07.735 2939-2952/letalis.safr.com.letalis W/OpenGLRenderer: Failed to set EGL_SWAP_BEHAVIOR on surface 0xab2c9da0, error=EGL_SUCCESS
09-07 07:36:07.942 2939-2952/letalis.safr.com.letalis V/RenderScript: 0xa21fe000 Launching thread(s), CPUs 2
09-07 07:36:08.053 2939-2952/letalis.safr.com.letalis E/Surface: getSlotFromBufferLocked: unknown buffer: 0xaebf1230
私はまた、コードの区切りとして星を置きます。乾杯:) – user6657161
おかげで、知って良いです:) – Zardoz
@Zardozエラーメッセージ –