/*
* Copyright (C) 2006 The Android Open Source Project
* Copyright (c) 2014-2016 Chukong Technologies Inc.
* Copyright (c) 2017-2018 Xiamen Yaji Software Co., Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.cocos2dx.lib;
import android.app.AlertDialog;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.res.AssetFileDescriptor;
import android.content.res.Resources;
import android.media.AudioManager;
import android.media.MediaPlayer;
import android.media.MediaPlayer.OnErrorListener;
import android.net.Uri;
import android.util.Log;
import android.view.Gravity;
import android.view.MotionEvent;
import android.view.SurfaceHolder;
import android.view.SurfaceView;
import android.widget.FrameLayout;
import android.widget.MediaController.MediaPlayerControl;
import java.io.IOException;
import java.util.Map;
public class Cocos2dxVideoView extends SurfaceView implements MediaPlayerControl {
private String TAG = "Cocos2dxVideoView";
private Uri mVideoUri;
private int mDuration;
// all possible internal states
private static final int STATE_ERROR = -1;
private static final int STATE_IDLE = 0;
private static final int STATE_PREPARING = 1;
private static final int STATE_PREPARED = 2;
private static final int STATE_PLAYING = 3;
private static final int STATE_PAUSED = 4;
private static final int STATE_PLAYBACK_COMPLETED = 5;
/**
* mCurrentState is a VideoView object's current state.
* mTargetState is the state that a method caller intends to reach.
* For instance, regardless the VideoView object's current state,
* calling pause() intends to bring the object to a target state
* of STATE_PAUSED.
*/
private int mCurrentState = STATE_IDLE;
private int mTargetState = STATE_IDLE;
// All the stuff we need for playing and showing a video
private SurfaceHolder mSurfaceHolder = null;
private MediaPlayer mMediaPlayer = null;
private int mVideoWidth = 0;
private int mVideoHeight = 0;
private OnVideoEventListener mOnVideoEventListener;
private MediaPlayer.OnPreparedListener mOnPreparedListener;
private int mCurrentBufferPercentage;
private OnErrorListener mOnErrorListener;
// recording the seek position while preparing
private int mSeekWhenPrepared;
protected Cocos2dxActivity mCocos2dxActivity = null;
protected int mViewLeft = 0;
protected int mViewTop = 0;
protected int mViewWidth = 0;
protected int mViewHeight = 0;
protected int mVisibleLeft = 0;
protected int mVisibleTop = 0;
protected int mVisibleWidth = 0;
protected int mVisibleHeight = 0;
protected boolean mFullScreenEnabled = false;
protected int mFullScreenWidth = 0;
protected int mFullScreenHeight = 0;
private int mViewTag = 0;
public Cocos2dxVideoView(Cocos2dxActivity activity,int tag) {
super(activity);
mViewTag = tag;
mCocos2dxActivity = activity;
initVideoView();
}
@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
if (mVideoWidth == 0 || mVideoHeight == 0) {
setMeasuredDimension(mViewWidth, mViewHeight);
Log.i(TAG, ""+mViewWidth+ ":" +mViewHeight);
}
else {
setMeasuredDimension(mVisibleWidth, mVisibleHeight);
Log.i(TAG, ""+mVisibleWidth+ ":" +mVisibleHeight);
}
}
public void setVideoRect(int left, int top, int maxWidth, int maxHeight) {
mViewLeft = left;
mViewTop = top;
mViewWidth = maxWidth;
mViewHeight = maxHeight;
fixSize(mViewLeft, mViewTop, mViewWidth, mViewHeight);
}
public void setFullScreenEnabled(boolean enabled, int width, int height) {
if (mFullScreenEnabled != enabled) {
mFullScreenEnabled = enabled;
if (width != 0 && height != 0) {
mFullScreenWidth = width;
mFullScreenHeight = height;
}
fixSize();
}
}
public int resolveAdjustedSize(int desiredSize, int measureSpec) {
int result = desiredSize;
int specMode = MeasureSpec.getMode(measureSpec);
int specSize = MeasureSpec.getSize(measureSpec);
switch (specMode) {
case MeasureSpec.UNSPECIFIED:
/* Parent says we can be as big as we want. Just don't be larger
* than max size imposed on ourselves.
*/
result = desiredSize;
break;
case MeasureSpec.AT_MOST:
/* Parent says we can be as big as we want, up to specSize.
* Don't be larger than specSize, and don't be larger than
* the max size imposed on ourselves.
*/
result = Math.min(desiredSize, specSize);
break;
case MeasureSpec.EXACTLY:
// No choice. Do what we are told.
result = specSize;
break;
}
return result;
}
private boolean mNeedResume = false;
@Override
public void setVisibility(int visibility) {
if (visibility == INVISIBLE) {
mNeedResume = isPlaying();
if (mNeedResume) {
mSeekWhenPrepared = getCurrentPosition();
}
}
else if (mNeedResume){
start();
mNeedResume = false;
}
super.setVisibility(visibility);
}
private void initVideoView() {
mVideoWidth = 0;
mVideoHeight = 0;
getHolder().addCallback(mSHCallback);
//Fix issue#11516:Can't play video on Android 2.3.x
getHolder().setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS);
setFocusable(true);
setFocusableInTouchMode(true);
mCurrentState = STATE_IDLE;
mTargetState = STATE_IDLE;
}
@Override
public boolean onTouchEvent(MotionEvent event) {
if((event.getAction() & MotionEvent.ACTION_MASK) == MotionEvent.ACTION_UP)
{
if (isPlaying()) {
pause();
} else if(mCurrentState == STATE_PAUSED){
resume();
}
}
return true;
}
private boolean mIsAssetRouse = false;
private String mVideoFilePath = null;
private static final String AssetResourceRoot = "assets/";
public void setVideoFileName(String path) {
if (path.startsWith(AssetResourceRoot)) {
path = path.substring(AssetResourceRoot.length());
}
if (path.startsWith("/")) {
mIsAssetRouse = false;
setVideoURI(Uri.parse(path),null);
}
else {
mVideoFilePath = path;
mIsAssetRouse = true;
setVideoURI(Uri.parse(path),null);
}
}
public void setVideoURL(String url) {
mIsAssetRouse = false;
setVideoURI(Uri.parse(url), null);
}
/**
* @hide
*/
private void setVideoURI(Uri uri, Map<String, String> headers) {
mVideoUri = uri;
mSeekWhenPrepared = 0;
mVideoWidth = 0;
mVid
没有合适的资源?快使用搜索试试~ 我知道了~
温馨提示
对于基于Cocos2d-X 3.17的跨平台单机麻将游戏,实现商业级麻将算法和AI算法的扩展是一个复杂而丰富的任务。首先,商业级麻将算法需要考虑到麻将游戏的规则和玩法,包括牌型判断、胡牌规则、杠牌规则等。在这方面,你可以使用一些经典的麻将算法,如基于数学统计的胡牌算法、基于搜索树的最优打牌算法等。这些算法可以帮助游戏实现更加智能和具有挑战性的对手。其次,AI算法的扩展可以通过引入深度学习技术来提高对手的智能水平。你可以使用神经网络来训练对手的决策模型,使其能够更好地理解游戏规则和对局情况,并做出更加合理的决策。此外,你还可以考虑引入强化学习算法,让对手通过不断的对局来优化自身的策略,从而提高游戏的可玩性和趣味性。总之,通过结合商业级麻将算法和AI算法的扩展,你可以打造出一款更加智能和具有挑战性的跨平台单机麻将游戏,吸引更多玩家的参与和喜爱。在实现过程中,你可以充分利用Cocos2d-X 3.17提供的强大功能和灵活性,使游戏具有更好的性能和用户体验。通过精心设计和优化算法,游戏可以实现更加智能的对手和更具挑战性的游戏体验。结合商业级麻将算法和AI算法的扩展,使得游戏更具吸引力。利用
资源推荐
资源详情
资源评论
收起资源包目录
基于Cocos2d-X3.17跨平台单机麻将商业级麻将算法AI算法 (2000个子文件)
libfreetype.a 2.63MB
libjpeg.a 2.2MB
libfreetype.a 1.44MB
libjpeg.a 1.11MB
libpng.a 1MB
libfreetype.a 571KB
libpng.a 559KB
libjpeg.a 254KB
libpng.a 216KB
libz.a 197KB
libglfw3.a 149KB
libz.a 79KB
gradlew.bat 2KB
ccFPSImages.c 175KB
vorbisfile.c 46KB
framing.c 31KB
bitwise.c 25KB
codebook.c 24KB
ConvertUTF.c 23KB
mdct.c 15KB
xxhash.c 15KB
primitives.c 13KB
floor0.c 12KB
md5.c 12KB
treminfo.c 12KB
floor1.c 11KB
dsp.c 9KB
res012.c 8KB
mapping0.c 8KB
format.c 6KB
floor_lookup.c 6KB
misc.c 6KB
cc_dummy.c 1KB
sweep.cc 23KB
shapes.cc 9KB
sweep_context.cc 5KB
advancing_front.cc 3KB
cdt.cc 2KB
UI.cfg 779B
COPYING 1KB
CCController-linux-win32.cpp 198KB
clipper.cpp 133KB
pvmp3_tables.cpp 89KB
CCDataReaderHelper.cpp 86KB
AudioMixer.cpp 80KB
CCImage.cpp 78KB
UIRichText.cpp 73KB
unzip.cpp 69KB
CCLabel.cpp 64KB
CCSGUIReader.cpp 63KB
CCActionInterval.cpp 62KB
GameEngine.cpp 55KB
CCNode.cpp 54KB
GameLayer.cpp 54KB
Java_org_cocos2dx_lib_Cocos2dxEngineDataManager.cpp 54KB
FlatBuffersSerialize.cpp 52KB
UILayout.cpp 51KB
CCSprite.cpp 51KB
CCEventDispatcher.cpp 50KB
tinyxml2.cpp 50KB
CCTexture2D.cpp 50KB
CSLoader.cpp 48KB
CCConsole.cpp 46KB
UIScrollView.cpp 44KB
CCParticleSystem.cpp 43KB
CCFileUtils.cpp 43KB
CCTransition.cpp 42KB
CCDirector.cpp 40KB
idl_parser.cpp 40KB
CCGLViewImpl-desktop.cpp 39KB
WidgetReader.cpp 38KB
ButtonReader.cpp 37KB
CCProperties.cpp 36KB
CCGLProgram.cpp 36KB
UIWidget.cpp 36KB
SliderReader.cpp 35KB
TabControlReader.cpp 35KB
CheckBoxReader.cpp 33KB
CCLayer.cpp 33KB
GameLogic.cpp 32KB
CCActionTimelineCache.cpp 31KB
CCDrawNode.cpp 31KB
CCGLProgramState.cpp 30KB
CCFastTMXLayer.cpp 30KB
LayoutReader.cpp 29KB
UIListView.cpp 29KB
CCScheduler.cpp 29KB
CCRenderTexture.cpp 29KB
CCParticleExamples.cpp 29KB
AudioResampler.cpp 28KB
CCRenderState.cpp 27KB
CCRenderer.cpp 27KB
pvmp3_framedecoder.cpp 27KB
CCTextureCache.cpp 27KB
CCTMXXMLParser.cpp 27KB
CCMenuItem.cpp 27KB
CCTMXLayer.cpp 26KB
UIButton.cpp 26KB
CCSpriteFrameCache.cpp 26KB
pvmp3_mpeg2_stereo_proc.cpp 26KB
共 2000 条
- 1
- 2
- 3
- 4
- 5
- 6
- 20
资源评论
传奇开心果编程
- 粉丝: 8086
- 资源: 335
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- 最全空间计量实证方法(空间杜宾模型和检验以及结果解释文档).txt
- 5uonly.apk
- 蓝桥杯Python组的历年真题
- 2023-04-06-项目笔记 - 第一百十九阶段 - 4.4.2.117全局变量的作用域-117 -2024.04.30
- 2023-04-06-项目笔记 - 第一百十九阶段 - 4.4.2.117全局变量的作用域-117 -2024.04.30
- 前端开发技术实验报告:内含4四实验&实验报告
- Highlight Plus v20.0.1
- 林周瑜-论文.docx
- 基于MIC+NE555光敏电阻的声光控电路Multisim仿真原理图
- 基于JSP毕业设计-基于WEB操作系统课程教学网站的设计与实现(源代码+论文).zip
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功